POV-Ray : Newsgroups : povray.general : Req: a #macro to reorient a vector : Re: Req: a #macro to reorient a vector Server Time
12 Aug 2024 23:19:34 EDT (-0400)
  Re: Req: a #macro to reorient a vector  
From: John VanSickle
Date: 2 Feb 1999 18:44:20
Message: <36B78EBB.CF5424E4@erols.com>
Peter Popov wrote:
> 
> I am following myself here, as it seems I didn't state the problem
> clearly enough. What I need is a #macro that works like the "Reorient"
> #macro on #Macroscope, but is used with a vector. Why?
> 
> Suppose you have a point A rotating  around the origin in the xz
> plane.Move the poiont up at the same time and you get a helix. What I
> want to do is a helix whose axis is defined by a function (a #macro,
> actually), so that it can be coiled aroind a circle, sine wave, or
> whatever else. How?

Well, to reorient a point (or a vector), it would go like this:

#macro vreorient(org_vec,start_vec,end_vec)
// org_vec is the point you want to perform the operation on
// start_vec is the original forward vector
// end_vec is the finishing forward vector

#local v_S=vnormalize(start_vec);
#local v_E=vnormalize(end_vec);
#local v_A=vcross(v_S,v_E);
#if (vlength(v_A)=0)
  (org_vec)
#else
  v_PS=vnormalize(vcross(v_A,v_S));
  v_PE=vnormalize(vcross(v_A,v_E));
  (vdot(org_vec,v_A)*v_A+vdot(org_vec,v_S)*v_E+vdot(org_vec,v_PS)*v_PE)
#end

Hope this helps,
John


Post a reply to this message

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