|
-
Oct 26th, 2008, 10:17 PM
#1
Thread Starter
Addicted Member
[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.)
-
Oct 26th, 2008, 10:37 PM
#2
Hyperactive Member
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.
-
Oct 26th, 2008, 11:54 PM
#3
Hyperactive Member
Re: VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)
 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.
-
Oct 27th, 2008, 09:39 AM
#4
Thread Starter
Addicted Member
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?
-
Oct 27th, 2008, 09:54 AM
#5
Hyperactive Member
Re: VB:6.0 - Rotate Points on a 2D X,Y Graph? (need math help)
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|