I'm trying to determine the distance to the edge of an ellipse with a given direction.
I have variables for both radii of the ellipse on the x and y scales, what I want to do is find the x and y on the ellipse when I have a given direction from the center so that I can calculate the distance at that given direction/point.
How would I do this?
Offline
I think that can be achieved through simple sine and cosine trigonometry.
X= sin(direction)*xradius
Y=cos(direction)*yradius
EDIT: This for portal sensing? I know what you're up to
Last edited by Kileymeister (2011-05-20 22:16:15)
Offline
Kileymeister wrote:
I think that can be achieved through simple sine and cosine trigonometry.
X= sin(direction)*xradius
Y=cos(direction)*yradius
Note: This is using Scratch direction, not math direction. For math direction, use "-1(direction-90)". (This note was actually kind of unnecessary, but whatever)
EDIT: This for portal sensing? I know what you're up to![]()
Yeah, I figured that out before you posted, but no, I'm not. I'm actually working on a radial gradient effect.
Offline
hmm...my overall equation isn't working though. Here's the design it produces, though it's different cuz I changed it so it's easier to see what happens:
My equation for the radial distance is the one messing up, I'm sure:
x=radius1*sin(atan(x-centerx/y-centery))
y=radius2*cos(atan(x-centerx/y-centery))
Then it uses the distance formula, distance=sqrt(x^2+y^2)
I've tried several variations of this, but they haven't worked. Anyone got any ideas why it's not doing it right?
Offline
Bump. Anyone?
If you need more information to figure this out:
the color= color1-((color2-color1)*(distance/radial distance)
So basically, when the ratio of distances is small, it's more color1, but if it's higher, it's more color2.
Offline
Ok, so I think I figured out what it's doing, but I don't understand why. It's drawing 2 circles around the focii of the ellipse. So if I make the focii equal (i.e. circle) it's fine, but if the radii are different (and thus, the focii are different), it doesn't work.
Offline