tracing a mathematical curve
Displaying 1-2 of 2 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Technetium

Suppose I have on paper an ellipse defined by the equation:

x^2 y^2
--- + --- = 1
4 9


Just to make it more complicated, suppose I rotate this ellipse 30 degrees, such that I now have the equation:

31 5 21
--x^2 + -sqrt(3)xy + --y^2 = 36
4 2 4

(I grabbed these equations from an old highschool textbook on rotating functions)

Okay, so here's my question. Let's say I want to use this ellipse in Verge, and each x and y correlates to a pixel's width. How do I rewrite this sort of equation to take a 3rd variable (the timer for example) to specify a point on the ellipse? In other words, if I wanted to move a tiny image around the ellipse, travelling an equal distance each time it 'updated', how would I do that? By 'distance' I don't mean just the X distance; I mean the hypotenuse of the triangle (would probably need good ol' Pythagorus here for starters) formed when going from one timer click to the next.

EDIT: Hope you guys can figure out the equations easily enough...

Posted on 2004-11-16 23:54:47 (last edited on 2004-11-16 23:55:34)

vecna

Its a bit simpler than what you're doing, but you might check out the timeless source code, many of the sprites files are doings lots of sincos stuff.

Totally bypassing your equations, I'd do something like:


mx = sin(timer*/speedfactor) * ellipse_width / 65535;
my = cos(timer*/speedfactor) * ellipse_height / 65535;

' */ ' denoting that you could multiply or divide or both to get the desired speed.

then you could rotate the resulting point by 30 degrees, add x and y centerpoint/anchor, and blit your object.

Your object will move an equidistant amount in degrees each tick.

Posted on 2004-11-17 03:15:52 (last edited on 2004-11-17 03:17:02)


Displaying 1-2 of 2 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.