|
![](/i/fill.gif) |
The first rotates an object such that if it oriented in the <from>
direction vector then after the rotation it will be oriented in the <to>
direction vector
The first relies in the second.
The second rotates an object around an axis <axis> by the angle <ang>
and was obtained from the src for the function vaxis_rotate (why wasn't
this type of rotation included in POV code) - hope the team don't mind :
)
This calculates a matrix for rotation.
eg cylinder{0,y,.1 lookat(y,<-0.5, 0.23, 0.342>) }
eg cylinder{0,y,.1 translate <0,0.5,.1> axis_rotate(x,45)}
#macro point(from, to)
#local axis = vcross(from,to);
#local axis = vnormalize(axis);
#local ang = acos(vdot(to,from)/vlength(to)/vlength(from));
axis_rotate(axis, ang)
#end
#macro axis_rotate(axis, ang)
#local cosx = cos(ang);
#local sinx = sin(ang);
matrix<
axis.x * axis.x + cosx * (1.0 - axis.x * axis.x),
axis.x * axis.y * (1.0 - cosx) + axis.z * sinx,
axis.x * axis.z * (1.0 - cosx) - axis.y * sinx,
axis.x * axis.y * (1.0 - cosx) - axis.z * sinx,
axis.y * axis.y + cosx * (1.0 - axis.y * axis.y),
axis.y * axis.z * (1.0 - cosx) + axis.x * sinx,
axis.x * axis.z * (1.0 - cosx) + axis.y * sinx,
axis.y * axis.z * (1.0 - cosx) - axis.x * sinx,
axis.z * axis.z + cosx * (1.0 - axis.z * axis.z),
0,0,0
>
#end
Hope these are of some use
Pabs
Post a reply to this message
|
![](/i/fill.gif) |