123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|605|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Cobra -> Another rotation maths question

Wed, 27 Jan 2010, 03:46
HoboBen
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.



Any ideas?

Thanks very much.




-=-=-
blog | work | code | more code
Wed, 27 Jan 2010, 03:49
Jayenkai
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!''
Wed, 27 Jan 2010, 03:52
HoboBen
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.)

-=-=-
blog | work | code | more code
Wed, 27 Jan 2010, 04:01
HoboBen
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

-=-=-
blog | work | code | more code
Wed, 27 Jan 2010, 04:09
Jayenkai
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!''
Wed, 27 Jan 2010, 04:16
HoboBen
Code's just a bit sloppy as I'm prototyping... Going to change a lot of my integers to reals.

-=-=-
blog | work | code | more code