|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi there,
I have a little problem with the rotation of an object.
I have 2 points, < x1 , y1 , z1 > and < x2 , y2 , z2 > , and an object at
the origin orientated in x-axis.
Now I want to rotate the object that way that it has the same direction that
the line from point 1 to point 2 has. The translation is done by other math,
I only need to rotate the object about origin.
I tried much with vnormalize() and so on, but the results never looked like
they should...
Thanks,
Nils
http://www.steini.de
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Try this: (untested at this point)
#declare p = <anynumber,0,0>;
#declare v1 = anyvector;
#declare v2 = anyothervector;
#declare v3 = v2 - v1;
#declare v4 = vnormalize(v3);
#declare zrot = degrees(atan2(v4.y,v4.x));
#declare yrot = degrees(atan2(v4.z,v4.x));
#declare p2 = vrotate(p,<0,yrot,zrot>);
p2 should have the new position of the object
You also might want to check out John VanSickle's Matrix page at
http://www.erols.com/vansickl/matrix.htm
Joshua
eng### [at] spiritonecom
Nils Steinkamp wrote:
>
> Hi there,
>
> I have a little problem with the rotation of an object.
>
> I have 2 points, < x1 , y1 , z1 > and < x2 , y2 , z2 > , and an object at
> the origin orientated in x-axis.
> Now I want to rotate the object that way that it has the same direction that
> the line from point 1 to point 2 has. The translation is done by other math,
> I only need to rotate the object about origin.
>
> I tried much with vnormalize() and so on, but the results never looked like
> they should...
>
> Thanks,
>
> Nils
>
> http://www.steini.de
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi there !
I fixed the problem by using
#declare NX = vnormalize( Punkt_naechster - Punkt_vorher ); // last
and next point
#declare NZ = vnormalize(vcross(NX,y));
#declare NY = vcross(NZ,NX);
object { Test2 // has to declared before
matrix < NX.x , NX.y , NX.z,
NY.x , NY.y , NY.z,
NZ.x , NZ.y , NZ.z,
Punkt_aktuell.x , Punkt_aktuell.y , Punkt_aktuell.z > //
the actuell translation
}
where the basic object is orientated from -x to +x
In this case the x-axis is orientated to the right, y-axis to the top and
z-axis from camera away to the depth of the room. The full code is
downloadable on my site, see adress at the end of the mail.
It works fine, when putting the object on a spline, it is rotated to follow
the spline.
Next step is the proclivity of the object to rotate it in x-axis left when
"flying" a left turn or right when "driving" a left turn.
Not as easy as it seems, but I'm on my way ;-)
Nils
http://www.steini.de
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
First off, I really like your web pages. Secondly, I'm just trying to do
something like you have shown here. Hopefully I can use your helpful
script to my benefit; that will of course depend on my ability to
understand it.
Nils Steinkamp wrote:
>
> Hi there !
>
> I fixed the problem by using
>
> #declare NX = vnormalize( Punkt_naechster - Punkt_vorher ); // last
> and next point
> #declare NZ = vnormalize(vcross(NX,y));
> #declare NY = vcross(NZ,NX);
>
> object { Test2 // has to declared before
> matrix < NX.x , NX.y , NX.z,
> NY.x , NY.y , NY.z,
> NZ.x , NZ.y , NZ.z,
> Punkt_aktuell.x , Punkt_aktuell.y , Punkt_aktuell.z > //
> the actuell translation
> }
>
> where the basic object is orientated from -x to +x
>
> In this case the x-axis is orientated to the right, y-axis to the top and
> z-axis from camera away to the depth of the room. The full code is
> downloadable on my site, see adress at the end of the mail.
>
> It works fine, when putting the object on a spline, it is rotated to follow
> the spline.
>
> Next step is the proclivity of the object to rotate it in x-axis left when
> "flying" a left turn or right when "driving" a left turn.
> Not as easy as it seems, but I'm on my way ;-)
>
> Nils
>
> http://www.steini.de
--
omniVERSE: beyond the universe
http://members.aol.com/inversez/homepage.htm
mailto://inversez@aol.com?Subject=PoV-News
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|