POV-Ray : Newsgroups : povray.off-topic : Vector math question.. : Vector math question.. Server Time
7 Sep 2024 03:19:56 EDT (-0400)
  Vector math question..  
From: Patrick Elliott
Date: 23 Aug 2008 18:15:31
Message: <48b08c03$1@news.povray.org>
Ok, first off, here is what I have to work with:

VecNorm = Normal for the vector.
VecMag = Magnitude of the vector.
Rot2Face = VecNorm(0,1,0) * VecMag.
Rot2Left = VecNorm(1,0,0) * VecMag.
Wind = returns a value of how "big" a force is blowing in x,y,z.
GetRot = Current rotation of the object.
SetForce = Set XForce, YForce and ZForce effecting the object.

Now, what I need to be able to do is take the objects rotation, figure 
out which way its "facing", then negate any movement that pushes it the 
opposite direction. This can be simple when in a fixed orientation, 
facing the same direction as the winds X, or Y. I just check if the wind 
vector is negative, I.e., blowing opposite the +X direction the object 
is facing, and throw out, or reverse the value, so its now blowing +X, 
instead of -X. This is however completely useless if/when trying to make 
it move in an unknown orientation.

Hmm. To simplify, assume that we are dealing with a wall that is the 
same "rotation" as the object itself, and that the object is a hanging 
cloth. I need to be able to determine when/if the wind vector is 
producing a push that is "towards" the wall, then invert it when that 
happens, so that the hanging blows "Away" from the wall, but the left to 
right movement needs to be the same as it would have been. So, in the 
simplest terms, where the facing is +X:

hanging.rot = <0,0,0>
if wind.x < 0
   wind.x *= -1;
SetForce(wind);

but how the hell do you do this if its like this?

hanging.rot = <10,30,0>
if ??????

I am guessing that the VecNorm will come into play, but I have no damn 
idea how. lol

Oh, and, just to make things more stupid, some bozo decided that euler 
vector can't be multiplied in the system I am working with. You can 
convert to a quaternion rotation, then do it, but not <1,2,3> * <3,2,1>. 
:p You can however do vect1.x = vect2.x * vect3.x, multiplying each 
value separately.

Note, I am not sure if I need z or not. I am not currently using it, but 
I suppose there may be cases where it could effect the result.

-- 
void main () {

     if version = "Vista" {
       call slow_by_half();
       call DRM_everything();
     }
     call functional_code();
   }
   else
     call crash_windows();
}

<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models, 
3D Content, and 3D Software at DAZ3D!</A>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.