27 December 2018, 13:01 | #1 |
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 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. |
27 December 2018, 13:21 | #2 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
I have been thinking of this before as well.. Basically, you describe your model in polar coordinates, and then transform to cartesian for projection/rendering. I can't remember if I used this for any demoscene-related stuff myself though..
|
27 December 2018, 13:24 | #3 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,987
|
It's called the polar coordinate system.
Yes, rotating becomes very easy. But scaling and/or moving objects will become quite difficult, especially if the direction of movement is not towards or away from the center point. |
27 December 2018, 13:47 | #4 | |
Registered User
Join Date: Dec 2017
Location: Denmark
Posts: 179
|
Quote:
Well thank you for the pointer, it will properly make it easier to get a better understanding of it, now that i know that a greek astronomer and astrologer figured this out 2200 years ago. |
|
27 December 2018, 23:53 | #5 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
|
The first time I'd heard of this was Andrew Braybrook's diary of a game for C64 Morpheus in 1987.
|
07 January 2019, 13:58 | #7 |
Registered User
Join Date: Jun 2015
Location: Germany
Posts: 1,918
|
There are lots of demos that use spherical coordinates for faster projection. You can usually see it because movement is restricted. You can fake a lot, e.g. project using table lookups and then just scale linearly to achieve the impression of varying distance. You can use perspectively incorrect direct projection. You can use a base vector for an object, project that correctly and then just project difference vectors from the base vector using smaller tables. You can use logarithmic tables to replace muls and divs by adds and subs.
All of these techniques have the problem that they are imprecise, visually incorrect and don't allow for random movement. They can be made to look good in a demo where you have everything under control but would hardly work well in games where the player decides the movement. E.g. the bump mapped bouncing ball from the above linked demo probably just uses some vertical linear stretching to achieve the bumping effect. How could you tell watching the demo that the angle of incident light is not changed correctly with the "deformation" of the ball? Demos are about faking something much more complex and that's the fun in them. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need explanation of a demo effect - screen zoom/rotate | Dunny | support.Demos | 21 | 21 April 2023 20:47 |
Rotate Shape - adds one pixel from left and top | peceha | Coders. Blitz Basic | 6 | 23 April 2018 22:18 |
WinUAE Assembly dump from point to point? | Sim085 | support.WinUAE | 3 | 11 April 2017 19:43 |
What's the point? | Mounty | project.WHDLoad | 7 | 24 January 2013 23:18 |
Is there any point????? | backtoskooldaze | support.Hardware | 1 | 06 April 2002 06:27 |
|
|