|
|
This is probably a simple question, but I just can't work the damn thing
out.
I'm writing an L-System app for use with Povray. Let's say I have a cylinder
lying along the positive x-axis, and I want to rotate it to be parallel to
the current forward vector of the L-System. What is the best way to do this?
I need it so any object can be substituted for the cylinder, hence object
rotations are required, rather than creating an object 'in-situ'.
If anyone knows of some free Delphi source for Lsystems, I'd appreciate the
link.
Thanx
Janger
Post a reply to this message
|
|
|
|
janger wrote:
> This is probably a simple question, but I just can't work the damn thing
> out.
> I'm writing an L-System app for use with Povray. Let's say I have a cylinder
> lying along the positive x-axis, and I want to rotate it to be parallel to
> the current forward vector of the L-System. What is the best way to do this?
Look at the pov links page for John Vansickles page & get his Reorient macro
--
Bye
Pabs
Post a reply to this message
|
|
|
|
"janger" <d_j### [at] hotmailcom> writes:
> This is probably a simple question, but I just can't work the damn thing
> out.
> I'm writing an L-System app for use with Povray. Let's say I have a cylinder
> lying along the positive x-axis, and I want to rotate it to be parallel to
> the current forward vector of the L-System. What is the best way to do this?
> I need it so any object can be substituted for the cylinder, hence object
> rotations are required, rather than creating an object 'in-situ'.
Remark that this isn't uniquely determined: If you rotate the object around
your vector, you get another solution. In case of a cylinder, it doesn't
make a difference, because of the symmetry of the cylinder. But if you
take a box instead of a cylinder, several (different) transformations
fulfill your requirements.
For the calculation of one of them, the easiest way is probably to use the
following theorem:
The rows of a matrix are the images of the unit vectors.
You want the first unit vector <1,0,0>, the one along the x-axis, to be mapped
to a given vector v=<v1,v2,v3>. The other unit vectors, <0,1,0> and <0,0,1>
should be mapped to vectors that are perpendicular to v. Let's call these
images u and w. One possibility to find such vectors is to use the cross
product of two vectors: Its result is a vector that is perpendicular to
the arguments of the cross product. We can use this as follows:
u := v cross <1,0,0>
w := v cross u
However, this doesn't work in the case that v is in x-direction, because then
u becomes <0,0,0>. (Fortunately for us, in this special case we don't need
any rotation.)
So, we get the following matrix:
(v1 u1 w1)
M = (v2 u2 w2)
(v3 u3 w3)
For a point p, the multiplication M*p is (one of) the desired transformations.
If you don't know, what the cross product of the product of a matrix with a
vector is, it is a good idea to have a look at a linear algebra book. You can
also find some information about this in the documentation of POV-Ray.
I hope this helps
Thomas
--
http://www.thomas.willhalm.de/ (includes pgp key)
Post a reply to this message
|
|
|
|
David Fontaine <dav### [at] faricynet> writes:
> It will be... (counting on fingers) ...too long before I have a vectors and
> matrices course. Math moves so slow.
Vectors and matrices aren't so difficult, in particular if you only need
two and three dimensional vectors.
Asking google, I have found a web page for you:
http://www.cs.cmu.edu/~rapidproto/handouts/vectors.html
It is a rather compact description of what you should know about vectors
for your purpose. Since the information density is quite high, don't
get frustrated, if you need several weeks to digest it. Then reread what
I wrote.
Afterwards you will agree that vectors are exactly what you need
for your POV-Ray projects (probably you already used them without noticing).
Bye
Thomas
--
http://www.thomas.willhalm.de/ (includes pgp key)
Post a reply to this message
|
|