|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hello,
Is there any macro available that will perform on an object the same
function as the look_at command does in a camera?
In other words, I have an object at <0,0,0> and oriented in the +z
direction, and I wish to perform an x-rotation then a y-rotation so that
the object is now pointing at a given point (as in the look_at point for
the Camera). I've been using John VanSickle's Reorient macro, but in
some cases the object receives an undesireable z-rotation so that it
becomes tilted wrong.
I've been banging my head for a while about this, any help would be
appreciated!
Andrew C
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Andrew Clinton wrote:
> ...and I wish to perform an x-rotation then a y-rotation ...
The instruction
rotate <xrot, yrot, 0>
will do the work.
See the povdoc section 4.3.1.3.
I hope this will help you
Alberto
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
No,no, thats not the problem. I mean that I am given a *point* (like a
look_at point), not the rotation values. Here is a camera:
camera {
location <0,0,0>
look_at <1,-2,3>
}
Pov-ray will automatically rotate the camera so that it is pointing at
<1,-2,3> while maintaining +y as the up direction (ie the horizon will
still be horizontal). What I need to find is the x-rotation and
y-rotation that are needed to properly align an object rather than a
camera to point at the point (because look_at can't be used with
objects!). It is very important that the object not change its z- tilt
for my purposes.
Your right, rotate <xrot,yrot,0> will work but I need the rotation
values first!
Thank you,
Andrew C
Alberto wrote:
> Andrew Clinton wrote:
>
> > ...and I wish to perform an x-rotation then a y-rotation ...
>
> The instruction
> rotate <xrot, yrot, 0>
> will do the work.
>
> See the povdoc section 4.3.1.3.
> I hope this will help you
> Alberto
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Yes!
// Reorient from <0,0,1> to p
#macro PointTo(p)
#if (0+p.x=0 & 0+p.y=0 & 0+p.z=0)
#local RotX=0;
#else
#local RotX=-atan2(p.y,sqrt(pow(p.x,2)+pow(p.z,2)))*180/pi;
#end
#if (0+p.x=0 & 0+p.z=0)
#local RotY=0;
#else
#local RotY=atan2(p.x,p.z)*180/pi;
#end
rotate <RotX,RotY,0>
#end
or
//reorient from vector 1 to vector 2
#macro reposition2(vec1,vec2)
#if (vlength(vec1)=0)
#render "Warning: reposition2 initial vector length is zero.\n"
#end
#if (vec1.x=0 & vec1.z=0)
#local RotY=0;
#else
#local RotY=atan2(vec1.x,vec1.z)*180/pi;
#end
#local RotX=asin((vec1.y)/vlength(vec1))*180/pi;
rotate -RotY*y
rotate RotX*x
#if (vlength(vec2)=0)
#render "Warning: reposition2 final vector length is zero.\n"
#end
#if (vec2.x=0 & vec2.z=0)
#local RotY=0;
#else
#local RotY=atan2(vec2.x,vec2.z)*180/pi;
#end
#local RotX=asin((vec2.y)/vlength(vec2))*180/pi;
rotate <-RotX,RotY,0>
#end
--
___ _______________________________________________
| \ |_ <dav### [at] faricynet> <ICQ 55354965>
|_/avid |ontaine http://www.faricy.net/~davidf/
"The only difference between me and a madman is that I'm not mad." -Dali
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
David Fontaine wrote:
> Yes!
I'm so enthusiastic cause nobody beat me to it with one of VanSickle's
macros... ;-)
--
___ _______________________________________________
| \ |_ <dav### [at] faricynet> <ICQ 55354965>
|_/avid |ontaine http://www.faricy.net/~davidf/
"The only difference between me and a madman is that I'm not mad." -Dali
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thank you :)
This is how I'm going to make the Megapov motion blur work - move the
objects backwards rather than move the camera forwards!
Andrew C
David Fontaine wrote:
> David Fontaine wrote:
>
> > Yes!
>
> I'm so enthusiastic cause nobody beat me to it with one of VanSickle's
> macros... ;-)
>
> --
> ___ _______________________________________________
> | \ |_ <dav### [at] faricynet> <ICQ 55354965>
> |_/avid |ontaine http://www.faricy.net/~davidf/
>
> "The only difference between me and a madman is that I'm not mad." -Dali
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
David Fontaine wrote:
> Yes!
8< Snip
> // Reorient from <0,0,1> to p
> #macro PointTo(p)
> #if (0+p.x=0 & 0+p.y=0 & 0+p.z=0)
> #local RotX=0;
> #else
> #local RotX=-atan2(p.y,sqrt(pow(p.x,2)+pow(p.z,2)))*180/pi;
8< Snip
Just a little suggestion for the last of these lines:
#local RotX = degrees(-atan2(p.y, vlength(p*(x+z)));
Regards
Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ahhh...
You may try this
#macro PointTo(p)
#local Rd = vlength(p);
#if(Rd = 0)
#local Rotx = 0;
#local Roty = 0;
#else
#local Rotx = 180*asin(p.y/Rd)/pi;
#if(p.z = 0)
#local Roty = 0;
#else
#local Roty = 180*atan2(p.x, p.z)/pi;
#end
#end
rotate <Rotx, Roty, 0>
#end
Alberto
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alberto wrote:
> Ahhh...
>
> You may try this
>
> #macro PointTo(p)
> #local Rd = vlength(p);
> #if(Rd = 0)
> #local Rotx = 0;
> #local Roty = 0;
> #else
> #local Rotx = 180*asin(p.y/Rd)/pi;
> #if(p.z = 0)
> #local Roty = 0;
> #else
> #local Roty = 180*atan2(p.x, p.z)/pi;
> #end
> #end
> rotate <Rotx, Roty, 0>
> #end
>
> Alberto
If that works then maybe this also works:
#macro PointTo(p)
#local RotVector = <0, 0, 0>;
#local Rd = vlength(p);
#if(Rd != 0)
#local RotVector = x*degrees(asin(p.y/Rd));
#if(p.z != 0)
#local RotVector = RotVector + y*degrees(atan2(p.x, p.z));
#end
#end
rotate RotVector
#end
But I haven't tested it...
Tor Olav
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Andrew Clinton wrote:
>
> Hello,
>
> Is there any macro available that will perform on an object the same
> function as the look_at command does in a camera?
>
> In other words, I have an object at <0,0,0> and oriented in the +z
> direction, and I wish to perform an x-rotation then a y-rotation so that
> the object is now pointing at a given point (as in the look_at point for
> the Camera). I've been using John VanSickle's Reorient macro, but in
> some cases the object receives an undesireable z-rotation so that it
> becomes tilted wrong.
My matrix page at
http://users.erols.com/vansickl/matrix.htm
has some sample code that may be useful.
Regards,
John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |