Latest Uploads
Rpg Potion Sprites

Pakz

Super Shap ... ration Kit

Andy_A

Platdude Spotting

Jayenkai

Nom nom nom

Jayenkai

Rainbow Trout

Pakz

King Salmon

Pakz

Forum Home

Another rotation maths question

UserMessage
Posted : Wednesday, 27 January 2010, 03:46 | Permalink
HoboBen


WW Entries : 9
I'm using this code to transform points of a vector graphic by offset, origin, scale and rotation.

It's mostly working except when I change the origin of rotation - a change in X origin works, but a change in Y origin doesn't quite (see image).

I can't figure out a way to change my code so that it works for a change in Y origin without then messing up the result when I have a change in X origin.

Highslide JS

Any ideas?

Thanks very much.


-->

-----
Posted : Wednesday, 27 January 2010, 03:49 | Permalink
Jayenkai


WW Entries : 106
I've just scanned it, not properly read what you're doing, but
"If (ToReal(pt.x - svg.xorigin) <> 0.0) then"
seems to be sticking out a bit.

|edit| Upon a proper reading, never mind.. |edit|

-----
"Load, Next List!"
Homepage : http://AGameAWeek.com
Posted : Wednesday, 27 January 2010, 03:52 | Permalink
HoboBen


WW Entries : 9
That's just to avoid a divide-by-zero error on the next line. (edit - though technically the else case should be Atan(INFINITY) instead - I've changed that now.)

-----
Posted : Wednesday, 27 January 2010, 04:01 | Permalink
HoboBen


WW Entries : 9
Hahahaha, I've got it!!!

This always happens - I work on things for hours and get nowhere, then after posting here for help I solve it it minutes!

Had to add this after sign = Sgn(theta)...

If ToReal(pt.y - svg.yorigin) < 0.0 then theta = theta + 180

That's all there was to it. Wooo!



edit - In TransformX to fix an occasional problem around y=0, I needed:
If (pt.y - svg.yorigin) < (-0.1 * Sgn(pt.x - svg.xorigin)) then theta = theta + 180.0

-----
Posted : Wednesday, 27 January 2010, 04:09 | Permalink
Jayenkai


WW Entries : 106
Hmm..
Seems a little odd, but ok!

Also, still not sure why you're doing Result=ToReal() when the function's listed as integer...

-----
"Load, Next List!"
Homepage : http://AGameAWeek.com
Posted : Wednesday, 27 January 2010, 04:16 | Permalink
HoboBen


WW Entries : 9
Code's just a bit sloppy as I'm prototyping... Going to change a lot of my integers to reals.

-----
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 561|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Latest Posts
Buy Zelda
rockford Sun 08:52
Repetitive Blogging
rskgames Fri 10:04
TinyBlocks
spinal Fri 06:46
Arduboy Owners Club
spinal Fri 02:30
AGameAWeek : 2017 - Part One
Jayenkai Thu 13:11
A New Korg Gadget!
Jayenkai Thu 12:30
SNES Mini?
rychan Thu 07:11
Steampunk Lamp
Jayenkai Wed 06:05
Finishing Off
rockford Tue 08:20
Weather in Games
rychan Tue 07:26
More

Latest Items
Showcase : Quadoban
rskgames Fri 10:11
Blog : My Arduino experience.
steve_ancell Wed 17:02
Showcase : Roguelike Explorer
Pakz Fri 06:59
Showcase : Infinitron
Jayenkai Mon 07:50
News : Newsletter #311
Jayenkai Thu 17:27
Link : Super Shapes Exploration Kit
Andy_A Thu 11:09
Dev-Diary : Sensitive - Arduboy!
rychan Thu 17:27
Snippet : Skylines
steve_ancell Tue 14:25
Dev-Diary : PS2 to N64 Adapter
spinal Sun 10:49
Link : Vector Tutorials/Help page.
Pakz Thu 23:00
Blog : mini project
spinal Sun 10:13
Showcase : Blockman Returns
Jayenkai Fri 03:04
Snippet : Wall Tracing on Random Maps (rpg)
rskgames Wed 22:48
Snippet : Path Following
Pakz Mon 16:25
More

Who's Online
Jayenkai
Sun, at 09:35
9572AD
Sun, at 09:16
rockford
Sun, at 08:54
rskgames
Sun, at 08:52
shroom_monk
Sun, at 08:25
Pakz
Sun, at 08:11
spinal
Sun, at 07:52
steve_ancell
Sun, at 02:35
Andy_A
Sat, at 14:01
rychan
Fri, at 04:50
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.