|
|
On 03/10/2018 07:10 PM, Mike Horvath wrote:
> How do I do the opposite of the `vrotate` command? E.g. I have two
> vectors, and need to know the <x,y,0> rotation angles to achieve the
> latter from the former? Thanks!!
>
>
> Mike
I just did this move. I assume you are looking at one thing and want to
look at another.
_i runs from 0..1, the duration of the move
_f perturbs _i by adding acceleration/deceleration. Still 0..1
VtoA() converts to angle
r0,r1 start,end angles
MoveV interpolate between r0,r1 by _f
#local _i=AniSegment(StartTime, EndTime);
#local _f=Curve0(_i);
#local v0=StartVec;
#local v1=EndVec;
#local r0=VtoA(v0-Camera);
#local r1=VtoA(v1-Camera);
#local rot=MoveV(r0,r1,_f);
#declare Lookat=vrotate(<0,0,1>, rot)+Camera;
///////////////////////////////////////////////////////////////////////////////////////////////////
// Convert this vector into its angle in degrees
#macro VtoA(V)
#local _V=vnormalize(V);
#local rZ=degrees(acos(_V.z));
#local rY=0;
#local rX=0;
#if (_V.y != 0)
#local rY=degrees(atan2(_V.x,_V.y));
#else
#local rX=rZ;
#local rZ=0;
#end
<-rZ,-rX,-rY>
#end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Move a Vector from, to, increment
#macro MoveV(_from, _to, __i)
<_from.x+((_to.x-_from.x)*__i),
_from.y+((_to.y-_from.y)*__i),
_from.z+((_to.z-_from.z)*__i)>
#end
///////////////////////////////////////////////////////////////////////////////////////////////////
#macro Curve0(_i)
(0.5-(cos(_i/2*pi2)/2))
#end
--
dik
Rendered 920576 of 921600 pixels (99%)
Post a reply to this message
|
|