View Single Post
Old 27 December 2018, 13:01   #1
LaBodilsen
Registered User
 
Join Date: Dec 2017
Location: Denmark
Posts: 179
A different way to rotate a point?

I don't know if this have been done before, but i've been pondering on this for a little while, and i think the idea came from a dot sphere in some demo. As i was watching this sphere, it came to me that every dot in this sphere could be described as an angle and distance from center, instead of a coordinate in a 3d world.

So what if we used this as a coordinate system where we describe each point as an angle and distance from center, eg 45,50 is angle = 45 and distance from center is 50. Then to rotate that point we could simply add the rotation angle to the initial angle, and voila be done with it.

To convert this angle,distance coodinate to screen space, we would derive the X coordinate with Sin(angle)*Distance, and the Y Coordinate with Cos(angle)*Distance.

example:
Coord: 22,50
X = Sin(22)*50 = 18,73
Y = Cos(22)*50 = 46,35

So the coord 22,50 would translate to X,Y coord (18,73),(46,35).

To rotate the point by 30 degree, we add that to the initial coord and get:
Coord: 52,50
X = Sin(52)*50 = 39,40
Y = Cos(52)*50 = 30,78

With this we can get a rotate loop without any multiplication, and only use addition.

I tried this out in assembler yesterday, and the code becomes very simple:

Code:
	lea	Plots,A0	;list of Angle coords
	lea	SinTable,A1	;Sintable start
	lea	CosTable,A2	;Costable start
	move.w	RotAngle,D5

.Rotate_Loop
	move.w	(A0)+,D2	;Coord Angle
	add.w	D5,D2		;Add rotation angle to angle coord
	and.w	#2047,D2	;Limit to Sin/Costable size	

.Convert_To_ScreenCoords
	move.w	(A0)+,D0	;Coord Distance
	move.w	D0,D1
	muls	(A1,D2),D0	;Convert X coord
	muls	(A2,D2),D1	;Convert Y coord
This is ofcourse only a 2D rotation, but i don't think expanding this to 3D would add that much complexity, eg expand the coord to (AngleZ,AngleX,AngleY,Distance) and convert that to screenspace. But creating objects in this angle,distance system might be pretty hard, but not impossible. Maybe a converter would be the best way.

So have this been done before?, and/or was it trashed for some reason. Any thoughts would be appreciated.

Last edited by LaBodilsen; 27 December 2018 at 13:20.
LaBodilsen is offline  
 
Page generated in 0.04428 seconds with 11 queries