Rotating a cube

J

J-Burns

Hello. Need some help here. I have a 4*4 cube. So the equation of the
cube becoming:

x + 4*y + 16*z

Now i want to rotate this cube 90 degrees anticlockwise( a right
rotation). How can i do that? The rotation must take place with the
axis of rotation being the straight line through the center of the
cube and perpendicular to the "xz-plane." The axis are aligned in this
fashion:

y
|
|
|________ x
/
/
z

Moreover, also tell me how to perform a rotation with the axis of
rotation being the straight line through the center of the cube and
perpendicular to the "yz-plane."

Essentially, I need the equations of the lines after the rotation has
been done in both cases.
Is there a built in Python function for this?
 
F

Fredrik Lundh

J-Burns said:
Is there a built in Python function for this?

for answering questions that have nothing to do with programming, and
looks quite a bit like homework? don't think they've added that one yet.

maybe you should look for a geometry newsgroup/forum?

</F>
 
J

J-Burns

for answering questions that have nothing to do with programming, and
looks quite a bit like homework? don't think they've added that one yet.

maybe you should look for a geometry newsgroup/forum?

</F>

I meant to ask how would you do this in Python... :S
 
N

norseman

J-Burns said:
Hello. Need some help here. I have a 4*4 cube. So the equation of the
cube becoming:

x + 4*y + 16*z

Now i want to rotate this cube 90 degrees anticlockwise( a right
rotation). How can i do that? The rotation must take place with the
axis of rotation being the straight line through the center of the
cube and perpendicular to the "xz-plane." The axis are aligned in this
fashion:

y
|
|
|________ x
/
/
z

Moreover, also tell me how to perform a rotation with the axis of
rotation being the straight line through the center of the cube and
perpendicular to the "yz-plane."

Essentially, I need the equations of the lines after the rotation has
been done in both cases.
Is there a built in Python function for this?
======================================

OH-Boy!

1) a regular cube is dimensioned having three mutually perpendicular
axis, each of same length. The 4x4 would be for a plane.
2) Clockwise IS Angles Right. (Rotate to right.)
Normal Angles Right would put zero at +Y, 90 at +X as viewed from +Z.
Norman Angles Right would put zero at +Z, 90 at +Y as viewed from +X.
Normal Angles Right would put zero at +Z, 90 at -X as viewed from +Y.
(there are six faces, finish the defs for the rest.)
3) Normally all rotations are defined as pivoting about the 0,0,0 point.
To use center of a plane or other pivot point is to add offsets.
4) Sequence of rotations controls final spatial orientation.

As for finding a cube handling graphic in the standard package download,
I did not. Somebody else can answer if there is a full blown Python
vector graphic package.

At a minimum you need to define a:
rotational routine that handles N 3D points as a single bundle.
The usual routines consider each rotation as being about a single axis.
It computes all N corners each time.
translation routine that moves N 3D points as a single bundle along a
single 3D vector.
It computes all N corners each time.
scaler routine that expands/contracts the relative distances between
the N 3D points using vectors from the computed 3D center.
It computes all N corners each time.
Some pre-/post routines to put things together to get the desired effects.

If N=0 (the nothing) there is nothing to do.
If N=1 (the point) there is no rotation or scale.
If N>1 (the line,plane,box,sphere,torus,etc.) then use all three.
(a sphere can be computed as three points of an isosceles triangle in
which the third side can equal the other two. The points then are used
to create a circle (ellipse) which is rotated about the third side.
In case it isn't obvious - the perpendicular bisector of the third side
is the center of the sphere. To track a point on a sphere is simply to
use 4 points. 0,1,2 are triangle and 3 is the point. Do your thing on
all 4, use 0,1,2 to remake sphere and 3 will be right place.)

The Chemical Rubber Company's Handbook of Physics and Chemistry is a
good starting point for the equations. Johnny, George, Willie and I
also used a few Celestial Mechanics books from the Library when we wrote
those in assembly in the long ago and far away. (back in the '60s on the
other side of the continent.) Sorry, but the punch cards disappeared
long ago and access to CAD programs deletes my need to re-write them.


Steve
(e-mail address removed)
 
L

Lie

I meant to ask how would you do this in Python... :S

The same as you do it in any other languages. This question is marked
correctly as having no relationship to python whatsoever. You'd get a
better answer if you asked in mathematics/geometry group, many
mathematician are adept programmer as well.
 
F

Fredrik Lundh

David said:
But is the question about display graphics ?

ie rotating a cube using a python framework ?

With something like python and OpenGL ? or Python and PovRay... or
perphaps python and imagemagick ?

can you name one graphics framework that represents a cube as "x + 4*y +
16*z" ?

</F>
 
S

Stef Mientki

Fredrik said:
can you name one graphics framework that represents a cube as "x + 4*y
+ 16*z" ?
no, but ...
I don't think the notation is so strange,
in electronics (and others) I'm used to a 2-dimensional complex notation:
vector = 3 + 4*i = 3*x +4*y

but although my English isn;t very well,
a "cube of 4*4" looks strange to me.

cheers,
Stef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top