Results 1 to 5 of 5

Thread: [RESOLVED] VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Resolved [RESOLVED] VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)

    I have no clue about the math needed for this. Please help me.

    I have several unknown points on a 2D graph. IE: -1,5 3,3 -7,-8 4,-9

    How would I rotate them X number of degrees? (A function would be appreciated.)

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)

    you can derive a formula from the sine and cosine sum formulas which would give you:

    Xr = X * cos(theta) - Y * cos(theta)
    Yr = Y * cos(theta) + X * cos(theta)

    where, Xr is the rotated x coordinate,Yr is the rotated y coordinate, and X and Y are the original coords. This assumes that you are rotating about the origin.

  3. #3
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Indiana
    Posts
    295

    Re: VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)

    Quote Originally Posted by wy125
    you can derive a formula from the sine and cosine sum formulas which would give you:

    Xr = X * cos(theta) - Y * cos(theta)
    Yr = Y * cos(theta) + X * cos(theta)

    where, Xr is the rotated x coordinate,Yr is the rotated y coordinate, and X and Y are the original coords. This assumes that you are rotating about the origin.
    Be aware that the angle theta must be in radians, not degrees since VB works in radians.

    To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.
    Last edited by Caskbill; Oct 27th, 2008 at 12:14 AM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Re: VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)

    So I get theta by multiplying degrees by pi/180?

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)

    Quote Originally Posted by Tontow
    So I get theta by multiplying degrees by pi/180?
    Well as Caskbill points out, VB assumes the angle is in radians for its trig functions such as sine and cosine. If you wish to use degrees as your basis, then you would will need to convert. If you wish to use radians, then no conversion is necessary. So, let's say you want to rotate your point by 30 degrees. Then you would need to convert as follows:

    Code:
    theta = 30 * pi / 180
    Now theta has a value in radians equivalent to 30 degrees and now the formulas are valid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width