|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I am not getting the results I want.
#declare light_source_location = vrotate(<0,0,-1>, <-060,-060,+000>);
#declare light_source_rotation = VtoA(light_source_location);
#debug "\n"
#debug concat("angles = ", vstr(3, light_source_rotation, ",", 0, -1), "\n")
#debug "\n"
The input and output angles do not match.
I would also rather omit the z angle in the result, so that there is
only rotation around the x and y axes.
Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I forgot I did this once already.
Mike
#macro vanglesXY(tVec2)
#local fSgnX = 1;
#local fSgnY = 1;
#local tPrjB1 = vnormalize(<tVec2.x, 0, tVec2.z>);
#if (tPrjB1.x != 0)
#local fSgnX = tPrjB1.x/abs(tPrjB1.x) * -1;
#end
#local tPrjB1 = <tPrjB1.x, tPrjB1.y, max(min(tPrjB1.z,1),-1)>;
#local fAngY = acosd(tPrjB1.z) * fSgnX;
#local tPrjB2 = vnormalize(vrotate(tVec2, <0, fAngY, 0>));
#if (tPrjB2.y != 0)
#local fSgnY = tPrjB2.y/abs(tPrjB2.y);
#end
#local tPrjB2 = <tPrjB2.x, tPrjB2.y, max(min(tPrjB2.z,1),-1)>;
#local fAngX = acosd(tPrjB2.z) * fSgnY;
<fAngX, (fAngY + 180) * -1, 0>
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 03/10/2018 11:53 PM, Mike Horvath wrote:
> I am not getting the results I want.
> #declare light_source_location = vrotate(<0,0,-1>, <-060,-060,+000>);
You know that this statement always gives a vlength(1) vector? (<-1,0,0>
or <0,1,0>) It's going to be real close to the origin. I'm thinking
that's not what you want.
Are you trying to move a light on a curve between two points? That is a
different thing than I presented.
> The input and output angles do not match.
They wouldn't with my formula. y is always 0. It's confusing to eyeball
"How can y be 0 when I'm clearly rotating 90 degrees around y". But
twiddling x/z gets you to the same place.
>
> I would also rather omit the z angle in the result, so that there is
> only rotation around the x and y axes.
You can build it as two separate x,y rotations if you know how to
degrees(atan2(V.y, V.z))
>
>
> Mike
--
dik
Rendered 920576 of 921600 pixels (99%)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|