|
|
Wlodzimierz ABX Skiba wrote:
>
> deform begining and end of normal and calculate returned direction ?
> this is wrong method
> sure, at first I thought of it but this not works with deformations
> why ?
> look on top surface of deformed box from begining of this thread
> this is flat before and after deformation
> and normal is parallel to axis of deformation
> but imagine normal before deformation
> normal's end_point twist just like other points and after deformation
> normal is not parallel to axis of deformation
> and smaller normal not help, direction is direction
>
> explain more ?
>
You're right, it probably cannot be done in a completely generic way
and would need to be done for each deformation. Mmm... maybe not as easy
as I first thought, let's see:
Let <nx, ny, nz> be the normal of the object before the deformation;
Let f be the transformation and fx, fy, fz its components;
Then the normal of the transformed point is:
<nx * dfx/dx + ny * dfy/dx + nz * dfz/dx,
nx * dfx/dy + ny * dfy/dy + nz * dfz/dy,
nx * dfx/dz + ny * dfy/dz + nz * dfz/dz>;
Therefore, all that's needed is to be able to compute the various
df*/d*. In the case of the twist transform along the y axis:
fx = cos(k*y)*x - sin(k*y)*z
fy = y
fz = sin(k*y)*x + cos(k*y)*z
And the transformed normal becomes:
<nx*cos(k*y) + nz*sin(k*y),
nx*(-k*sin(k*y)*x-k*cos(k*y)*z) + ny + nz*(k*cos(k*y)*x-k*sin(k*y)*z),
nx*(-sin(k*y)) + nz*cos(k*y)>
Notice that for the flat faces, nx=0, ny=1 (or -1), nz=0 and the
transformed normal is correct.
Hope this helps,
--
* Abandon the search for truth, * mailto:ber### [at] inamecom
* Settle for a good fantasy. * http://www.enst.fr/~jberger
*********************************
Post a reply to this message
|
|