POV-Ray : Newsgroups : povray.off-topic : Vector math question.. : Re: Vector math question.. Server Time
10 Oct 2024 03:08:44 EDT (-0400)
  Re: Vector math question..  
From: Patrick Elliott
Date: 23 Aug 2008 23:56:08
Message: <48b0dbd8$1@news.povray.org>
John VanSickle wrote:
> Patrick Elliott wrote:
>> 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.
> 
> Take the dot product of the pushing force vector (not normalized) and 
> the vector for the facing object (normalized), and check the sign.  If 
> the sign is negative (force and facing opposed to some degree), then 
> multiply the dot product by the normalized value of the pushing force, 
> and then subtract this from the pushing force, to yield a vector that is 
> perpendicular to the pushing force.
> 
> Regards,
> John

Ok, so umm, basically, like:

objnorm = VecNorm(GetRot);
windnorm = VecNorm(wind);
xdot = Wind.x * objface.x;
ydot = Wind.y * objface.y;
if xdot < 0
   Wind.x -= xdot * windnorm.x;
if ydot < 0
   Wind.y -= ydot * windnorm.y;
SetForce (Wind);

Now, I think this just reverses the force, right, so if I wanted to make 
it got the reverse way, I would double the result of the dot product * 
the force, so it move the reverse direction, not just negates it?

-- 
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.