thanks but I lied a bit, I really want 4 points in a box formation to rotate around a central point - while keeping the formation.
The problem seems to be that the angle (in the above formula), is related to world coordinates not related to the object. I need to add /subtract extra degrees for each point and it's in adding and subtracting, things start to go wrong .. as you can gather at this point, I'm no mathematician.
Here's my test code .. don't laugh! :)
Graphics 800, 600, 32, 2
Cls
x1# = 200.0
z1# = 200.0
x2# = 250.0
z2# = 200.0
x3# = 200.0
z3# = 250.0
x4# = 250.0
z4# = 250.0
ax# = 350.0
az# = 350.0
deg# = 45.0
Color 250, 0, 0
Oval ax#, az#, 3, 3, True
For d = 0 To 360 Step 45
Radius1# = Sqr( (ax#-x1#)^2 + (az#-z1#)^2 )
NewAng1# = ASin( (ax#-x1#) / radius1# )
x1# = ax# + Cos( d-NewAng1# ) * radius1#
z1# = az# + Sin( d-NewAng1# ) * radius1#
Radius2# = Sqr( (ax#-x2#)^2 + (az#-z2#)^2 )
NewAng2# = ASin( (ax#-x2#) / radius2# )
x2# = ax# + Cos( d-NewAng2# ) * radius2#
z2# = az# + Sin( d-NewAng2# ) * radius2#
Radius3# = Sqr( (ax#-x3#)^2 + (az#-z3#)^2 )
NewAng3# = ASin( (ax#-x3#) / radius3# )
x3# = ax# + Cos( d-NewAng3# ) * radius3#
z3# = az# + Sin( d-NewAng3# ) * radius3#
Radius4# = Sqr( (ax#-x4#)^2 + (az#-z4#)^2 )
NewAng4# = ASin( (ax#-x4#) / radius4# )
x4# = ax# + Cos( d-NewAng4# ) * radius4#
z4# = az# + Sin( d-NewAng4# ) * radius4#
Color 250, 250, 250
Rect x1# , z1#, 20, 20
Rect x2# , z2#, 20, 20
Rect x3# , z3#, 20, 20
Rect x4# , z4#, 20, 20
Delay 2000
Next
WaitKey()
The problem seems to be that the angle (in the above formula), is related to world coordinates not related to the object. I need to add /subtract extra degrees for each point and it's in adding and subtracting, things start to go wrong .. as you can gather at this point, I'm no mathematician.
Here's my test code .. don't laugh! :)
Graphics 800, 600, 32, 2
Cls
x1# = 200.0
z1# = 200.0
x2# = 250.0
z2# = 200.0
x3# = 200.0
z3# = 250.0
x4# = 250.0
z4# = 250.0
ax# = 350.0
az# = 350.0
deg# = 45.0
Color 250, 0, 0
Oval ax#, az#, 3, 3, True
For d = 0 To 360 Step 45
Radius1# = Sqr( (ax#-x1#)^2 + (az#-z1#)^2 )
NewAng1# = ASin( (ax#-x1#) / radius1# )
x1# = ax# + Cos( d-NewAng1# ) * radius1#
z1# = az# + Sin( d-NewAng1# ) * radius1#
Radius2# = Sqr( (ax#-x2#)^2 + (az#-z2#)^2 )
NewAng2# = ASin( (ax#-x2#) / radius2# )
x2# = ax# + Cos( d-NewAng2# ) * radius2#
z2# = az# + Sin( d-NewAng2# ) * radius2#
Radius3# = Sqr( (ax#-x3#)^2 + (az#-z3#)^2 )
NewAng3# = ASin( (ax#-x3#) / radius3# )
x3# = ax# + Cos( d-NewAng3# ) * radius3#
z3# = az# + Sin( d-NewAng3# ) * radius3#
Radius4# = Sqr( (ax#-x4#)^2 + (az#-z4#)^2 )
NewAng4# = ASin( (ax#-x4#) / radius4# )
x4# = ax# + Cos( d-NewAng4# ) * radius4#
z4# = az# + Sin( d-NewAng4# ) * radius4#
Color 250, 250, 250
Rect x1# , z1#, 20, 20
Rect x2# , z2#, 20, 20
Rect x3# , z3#, 20, 20
Rect x4# , z4#, 20, 20
Delay 2000
Next
WaitKey()