Results 1 to 1 of 1

Math Help - Rotate a circle in the space

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    1

    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 Thumbnails Attached Thumbnails Rotate a circle in the space-circleill.jpg  
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Rotate Vector
    Posted in the Trigonometry Forum
    Replies: 6
    Last Post: February 2nd 2011, 11:11 PM
  2. Tangent Vector to a Space Circle
    Posted in the Calculus Forum
    Replies: 2
    Last Post: January 14th 2011, 12:49 PM
  3. Equation of a circle in 3D space
    Posted in the Geometry Forum
    Replies: 1
    Last Post: August 13th 2008, 01:53 PM
  4. rotate conic
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: May 21st 2008, 11:01 AM
  5. Using sin and cos to rotate a point
    Posted in the Trigonometry Forum
    Replies: 1
    Last Post: September 10th 2007, 09:07 AM

Search Tags


/mathhelpforum @mathhelpforum