|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Here is the situation: A macro will create an object, and one of the
parameters specifies the "up" vector of the desired object. The macro will
generate an object initially at the origin with a hard-coded "up" direction
(say, +y) and then translate/rotate into the final location. Translate is
easy. How about rotate? In this case, I want to compute the arguments to
'rotate' so that what was +y now points paralell to the Up parameter.
The axis of rotation would be the cross product of the old and new up's.
The angle can also be figured from this (I don't know the formula off hand,
but it's not a big mystery). BUT, POV wants a rotate command giving x,y,z
component angles. There isn't a form to rotate (the enclosing object) by a
specific amount along a specified axis.
Anyone have the answer?
TIA,
--John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
John M. Dlugosz wrote:
>
> Here is the situation: A macro will create an object, and one of the
> parameters specifies the "up" vector of the desired object. The macro will
> generate an object initially at the origin with a hard-coded "up" direction
> (say, +y) and then translate/rotate into the final location. Translate is
> easy. How about rotate? In this case, I want to compute the arguments to
> 'rotate' so that what was +y now points paralell to the Up parameter.
>
> The axis of rotation would be the cross product of the old and new up's.
> The angle can also be figured from this (I don't know the formula off hand,
> but it's not a big mystery). BUT, POV wants a rotate command giving x,y,z
> component angles. There isn't a form to rotate (the enclosing object) by a
> specific amount along a specified axis.
>
> Anyone have the answer?
>
> TIA,
> --John
If I recall correctly there are (or is) a couple of macros at twysts
macro station that address normalizing an object in reference to the
origin. This I think is what you are attempting.
The alternative is constructing the object at origin, rotating it,
and then applying the translations you need to make. This will allow you
to maintain any rotational attribute you have given the object.
http://twysted.net
--
Ken Tyler
mailto://tylereng@pacbell.net
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Another one in this discussion, I have several rotate and a translate, as this :
rotate <nX,0,0>
rotate <0,nY,0>
rotate <0,nZ,0>
translate <0,nL,0>
Now I wonder, is it possible to make this into only one rotate/translate, or,
even better into a matrix (I don't know the math, I only want to know if it is
possible, as so far.)
If it is possible to make only one matrix, can I combine two of them into only
one ?? (yes, macro :-)
"John M. Dlugosz" wrote:
>
> Here is the situation: A macro will create an object, and one of the
> parameters specifies the "up" vector of the desired object. The macro will
> generate an object initially at the origin with a hard-coded "up" direction
> (say, +y) and then translate/rotate into the final location. Translate is
> easy. How about rotate? In this case, I want to compute the arguments to
> 'rotate' so that what was +y now points paralell to the Up parameter.
>
> The axis of rotation would be the cross product of the old and new up's.
> The angle can also be figured from this (I don't know the formula off hand,
> but it's not a big mystery). BUT, POV wants a rotate command giving x,y,z
> component angles. There isn't a form to rotate (the enclosing object) by a
> specific amount along a specified axis.
>
> Anyone have the answer?
>
> TIA,
> --John
--
//Spider
( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
#declare life = rand(seed(42))*sqrt(-1);
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Spider schrieb in Nachricht <36D99EA7.F4436A97@bahnhof.se>...
>Another one in this discussion, I have several rotate and a translate, as
this :
>
>
>rotate <nX,0,0>
>rotate <0,nY,0>
>rotate <0,nZ,0>
>translate <0,nL,0>
>
>Now I wonder, is it possible to make this into only one rotate/translate,
or,
>even better into a matrix (I don't know the math, I only want to know if it
is
>possible, as so far.)
>If it is possible to make only one matrix, can I combine two of them into
only
>one ?? (yes, macro :-)
Yes, you can, using matrix multiplication. There is a good tutorial
somewhere on the web (John's Pov Matrix Page:
http://www.erols.com/vansickl/matrix.htm). I would recommend reading this.
It's good. You can also find this in any math textbook.
But you could *propably* just as well combine the rotations like this:
rotate <nX, nY + nZ, 0>
translate nL * y
I think this is the correct order POV-Ray does this.
--
Rudy Velthuis
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thankyou.
Reading tutor now.
I have some linear algebra textbooks here, but I'm not good enough to actually
understand anything from it(and I have to finish that class soon. *sigh*)
I'll try the last one.
Rudy Velthuis wrote:
>
> Spider schrieb in Nachricht <36D99EA7.F4436A97@bahnhof.se>...
> >Another one in this discussion, I have several rotate and a translate, as
> this :
> >
> >
> >rotate <nX,0,0>
> >rotate <0,nY,0>
> >rotate <0,nZ,0>
> >translate <0,nL,0>
> >
> >Now I wonder, is it possible to make this into only one rotate/translate,
> or,
> >even better into a matrix (I don't know the math, I only want to know if it
> is
> >possible, as so far.)
> >If it is possible to make only one matrix, can I combine two of them into
> only
> >one ?? (yes, macro :-)
>
> Yes, you can, using matrix multiplication. There is a good tutorial
> somewhere on the web (John's Pov Matrix Page:
> http://www.erols.com/vansickl/matrix.htm). I would recommend reading this.
> It's good. You can also find this in any math textbook.
>
> But you could *propably* just as well combine the rotations like this:
>
> rotate <nX, nY + nZ, 0>
> translate nL * y
>
> I think this is the correct order POV-Ray does this.
> --
> Rudy Velthuis
--
//Spider
( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
#declare life = rand(seed(42))*sqrt(-1);
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ken wrote in message <36D99775.CAF9A4D1@pacbell.net>...
> The alternative is constructing the object at origin, rotating it,
>and then applying the translations you need to make. This will allow you
>to maintain any rotational attribute you have given the object.
That =is= what I'm doing.
You could write a macro like this:
object {
MyThing (/* controlling parameters... */ , Pos, Orientation)
// ...
as an alternative to writing
object {
MyThing (/* controlling parameters... */)
rotate Orientation
translate Pos
// ...
with the advantage that the macro =knows= about that information and can
adjust itself accordingly.
However, I would find it more convenient to specify the "Orientation"
information not as the kind of x,y,z angles you normally give to "rotate",
but as a vector that points in the object's "Forward" direction. This is
much more useful for computing object details within the macro, and I want
to develop a general technique based on it.
So, how do I turn the Forward vector into something that the "rotate"
command likes?
--John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Spider wrote in message <36D99EA7.F4436A97@bahnhof.se>...
>Another one in this discussion, I have several rotate and a translate, as
this :
>
>
>rotate <nX,0,0>
>rotate <0,nY,0>
>rotate <0,nZ,0>
>translate <0,nL,0>
>
>Now I wonder, is it possible to make this into only one rotate/translate,
or,
>even better into a matrix (I don't know the math, I only want to know if it
is
>possible, as so far.)
>If it is possible to make only one matrix, can I combine two of them into
only
>one ?? (yes, macro :-)
It sure is. I don't know if it's worth doing it in POV script, though.
It's not exactly an object-oriented language.
matrix M= I; // identity matrix
M.rotate (n*x);
M.rotate (n*y);
M.rotate (n*z);
M.translate (whatever);
// ... later
someObject.rotate (M); // do the whole thing as one step
anotherObject.rotate (M); // same value used here.
--John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I can't say I understand this. some more explination please.
As you do it, I get that M is anew matrix pointer at I, then you apply a rotate
to a matrix ???? Hmm, don't get that at all.
"John M. Dlugosz" wrote:
>
>
> It sure is. I don't know if it's worth doing it in POV script, though.
> It's not exactly an object-oriented language.
>
> matrix M= I; // identity matrix
> M.rotate (n*x);
> M.rotate (n*y);
> M.rotate (n*z);
> M.translate (whatever);
> // ... later
> someObject.rotate (M); // do the whole thing as one step
> anotherObject.rotate (M); // same value used here.
>
> --John
--
//Spider
( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
#declare life = rand(seed(42))*sqrt(-1);
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
A matrix does any kind of linear transform. Rotate is one such transform.
Every rotate, translate, or shear is represeted as a matrix. A point is
represented as a vector. To transform the point, multiply the point by the
matrix. To do two things, say a rotate followed by another rotate, multiply
the point by the first matrix, then multiply the result by the second
matrix. IOW,
result= p * M1 * M2;
Now it happens that you can also multiply the two matrices together, which
creates a single matrix that does the same thing! IOW,
result= p * (M1*M2);
the multiplication is associative. (Note that it is not commutative,
though).
So you could write:
matrix M3= M1*M2;
result= p*M3;
and get the same answer, and reuse M3 many times with less work.
So in my notes, M.rotate is just a function that changes M to be whatever it
was before and the desired rotation on top of that.
Something like this:
void matrix::rotate (const vector& input)
{
matrix rotX= (
1, 0, 0,
0, cos(deg_to_rad(input.x)), sin(deg_to_rad(input.x)),
0, -sin(deg_to_rad(input.x)), cos(deg_to_rad(input.x)) );
matrix rotY= /// similar logic
matrix rotZ= /// similar logic -- look it up in a Linear Algebra book.
(*this) = (*this) * rotX * rotY * rotZ;
}
This takes a vector holding separate x, y, and z angles in degrees, and
folds them into the original matrix.
--John
Spider wrote in message <36DACFFA.B2203C07@bahnhof.se>...
>I can't say I understand this. some more explination please.
>As you do it, I get that M is anew matrix pointer at I, then you apply a
rotate
>to a matrix ???? Hmm, don't get that at all.
>
>"John M. Dlugosz" wrote:
>>
>>
>> It sure is. I don't know if it's worth doing it in POV script, though.
>> It's not exactly an object-oriented language.
>>
>> matrix M= I; // identity matrix
>> M.rotate (n*x);
>> M.rotate (n*y);
>> M.rotate (n*z);
>> M.translate (whatever);
>> // ... later
>> someObject.rotate (M); // do the whole thing as one step
>> anotherObject.rotate (M); // same value used here.
>>
>> --John
>
>--
>//Spider
>( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
>#declare life = rand(seed(42))*sqrt(-1);
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thankyou.
I'm actually looking for a way to reduce the filesize of my tree macro creator,
preferable by removing some of the rotate, into either a single one or into a
matrix. I'm uncertain what would be easiest for me to do. I don't intend to do a
big time recode for a small saving, but if I can do it with some ease, I will.
--
//Spider
( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
#declare life = rand(seed(42))*sqrt(-1);
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|