Nenad Milosavljevic
Nenad Milosavljevic

Reputation: 147

calculating angle between two figures openGL

result this is how result should look in the end. The question is, how can i calculate angle by which i have to rotate each of these prisms (i have function which draws single prism - height of prism and trapezoid are known)?

Upvotes: 0

Views: 338

Answers (3)

Dinesh Subedi
Dinesh Subedi

Reputation: 2663

In this example you have 6 prisms so you can rotate prism by 60 degrees but case not be same for all time. So try to use the math formula to calculate the angle. Lets take the example. You have a line (x1,y1,z1) to (x2,y2,z2) If you want to rotate it about z-axis then calculate the angle like this.

inverse of tan (p/b) where p = y2-y1 and b = x2 -x1

which gives the angle of rotation about z-axis.

Now, rotating about y-axis:

p=z2-z1 and b=x2-x1

Again, rotating about x-axis:

p=y2-y1 and b=z2-z1

Upvotes: 1

Iftah
Iftah

Reputation: 9572

well you have 6 prisms to complete a 360 degrees loop, so from the symmetry of it you should rotate each prism by 60 degrees (ie. pi/3)

Upvotes: 0

Emanuele Paolini
Emanuele Paolini

Reputation: 10162

You want to subdivide a complete rotation in 6 parts. So your angle is 360/6 = 60 degrees.

Upvotes: 0

Related Questions