Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Pre-University Math Help > Trigonometry
Reply
 
Thread Tools Display Modes
  #1  
Old November 3rd, 2009, 04:37 AM
Newbie
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Anne Holmen is on a distinguished road
Default Rotate a circle in the space

I'm trying to make a circle that has a center in origo. I make this in the GDL programming language. But the problem is actually related to trigonometry.
So I need some help from clever matematics people.
Se the illustration below.
I first put the circle on the horizontal layer (XY-layer and z=0). Center is origo (x=y=z=0)
That works fine.
I tilt the circle with an angle to the horizontal layer. I call this angleXY.
The circle cuts through the horizontal layer in the X-axis. The circle is tiltet counter-clockwise. This also works fine.
But the problem occures when I try to rotate the tilted circle counterclockwise around the z-axis. The angle is vinkeXZ. I can't figure out how to calculate the x-coordinates.

Here is the code (vinkel = angle)
fromDegrees = 10
toDegrees = 360
stepDegrees = 10
centerX = 0
centerY = 0
centerZ = 0
radiusP = 0.5
vinkelXZ = 45 ! Angle from the X-axis counterclockwise around the Z-axis (centerX and centerY=0)
vinkelXY = 45 ! Angle between the horizontal-layer and the circle.
! Counterclockwise around the X-axis (centerY=0)
angle = 0
GOSUB "GenerateCircularCoordinates"


END


"GenerateCircularCoordinates":
! This routine calculates xyz-coordinates to a circle that tilts against the horizontal-layer
! and rotates around the Z-axis
!
! Calculate the trigonometric factores to angles that do not change in the loop.
sinVinkelXY = SIN(vinkelXY)
cosVinkelXY = COS(vinkelXY)
sinVinkelXZ = SIN(vinkelXZ)
cosVinkelXZ = COS(vinkelXZ)

FOR vinkel = fromDegrees TO toDegrees STEP stepDegrees
deltaX = radiusP * COS (vinkel)
deltaY = radiusP * SIN (vinkel)
deltaZ = radiusP * SIN (vinkel)

x = centerX - deltaX
y = centerY - deltaY
z = centerZ
! ---------------------------------------------------
! Tilt against the horizontal-layer (XY-layer)
! Rotation around the X-axis
!
z = -y * sinVinkelXY + centerZ
y = y * cosVinkelXY + centerY
! ---------------------------------------------------
! Rotation around the Z-axis
!
y = y + x*sinVinkelXZ
x = x*cosVinkelXZ
!
! PUT x, y, z, angle
IF vinkel <> 0 THEN
ADD x, y, z
TEXT 0.005, 0, vinkel
DEL 1
LIN_ x - 0.01, y - 0.01, z - 0.01, x + 0.01, y + 0.01, z + 0.01
!ENDIF

NEXT vinkel
RETURN
Attached Images
 
Reply With Quote
Advertisement
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 12:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.