Circle rotation in space. Can't calculate x coordinate.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2009-11-03 12:47 PM
‎2009-11-03
12:47 PM
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 tilted 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. I 've tryed many formulas, but the coordinates eighter give me an ellipsis or a line.
Here is the code (vinkel norwegian for 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
12 REPLIES 12
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2009-11-04 05:19 PM
‎2009-11-04
05:19 PM
Anne wrote:Poor Norwegian husbands...
I tested out my husbands brain yesterday... (...) A friend of me told me today that her husband was really good in mathematics, so I have to test him😉
![](/legacyfs/online/emojis/icon_lol.gif)
![Ralph Wessel Ralph Wessel](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_462.jpg)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2009-11-04 07:02 PM
‎2009-11-04
07:02 PM
Anne wrote:Try the script below. I've typed this from memory, so it might have errors. Hopefully the comments make the meaning clear.
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. I 've tryed many formulas, but the coordinates eighter give me an ellipsis or a line.
!----------------------------------------------------------- !Set up rotation angles ! xRotationAngle is rotation angle about X axis ! zRotationAngle is rotation angle about Z axis !----------------------------------------------------------- cosX = cos(-xRotationAngle) sinX = sin(-xRotationAngle) cosZ = cos(-zRotationAngle) sinZ = sin(-zRotationAngle) !Rotate a point about 'X' axis xIn = 20 yIn = 5 zIn = 0 gosub "doXRotate" !Rotate about 'Z' axis gosub "doZRotate" !The rotated point is contained in (xIn, yIn, zIn) end !----------------------------------------------------------- ! Rotate a point about the x axis ! In/Out: ! yIn: The Y coordinate of the point to rotate ! zIn: The Z coordinate of the point to rotate !----------------------------------------------------------- "doXRotate": yOut = zIn * sinX + yIn * cosX zIn = zIn * cosX - yIn * sinX yIn = yOut return !----------------------------------------------------------- ! Rotate a point about the z axis ! In/Out: ! xIn: The X coordinate of the point to rotate ! yIn: The Y coordinate of the point to rotate !----------------------------------------------------------- "doZRotate": xOut = xIn * cosZ + yIn * sinZ yIn = -xIn * sinZ + yIn * cosZ xIn = xOut return
Ralph Wessel BArch
Active Thread Ltd
Active Thread Ltd
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2009-11-05 11:05 AM
‎2009-11-05
11:05 AM
This worked fine! You deserve a big hug
![](/legacyfs/online/emojis/icon_biggrin.gif)
- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »