Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
rotated ellipse in cartesian coordinates

Subject: rotated ellipse in cartesian coordinates

From: Fabian

Date: 9 Dec, 2008 07:12:05

Message: 1 of 5

I've got a matlab procedure that fits an ellipse to a set of points, my problem is that I only need a certain x range and x-step in cartesian coordinate system. Can somebody help me with a formula for y as a function of x and my ellipse (defined by [z, a, b, alpha] returned by fitellipse:)
%parameterised by 0 <= theta < 2*pi is:
X = Z + Q(alpha) * [a * cos(theta);b * sin(theta)]

Subject: rotated ellipse in cartesian coordinates

From: Adam

Date: 9 Dec, 2008 13:16:02

Message: 2 of 5

"Fabian" <fabian.conrad@gmx.de> wrote in message <ghl5o5$29q$1@fred.mathworks.com>...
> I've got a matlab procedure that fits an ellipse to a set of points, my problem is that I only need a certain x range and x-step in cartesian coordinate system. Can somebody help me with a formula for y as a function of x and my ellipse (defined by [z, a, b, alpha] returned by fitellipse:)
> %parameterised by 0 <= theta < 2*pi is:
> X = Z + Q(alpha) * [a * cos(theta);b * sin(theta)]

Does it have to be x and y? That would be awkward.

http://en.wikipedia.org/wiki/Ellipse

Parametric form of an ellipse rotated counterclockwise by an angle k

    x = h + a * cos(t) * cos(k) - b * sin(t) * sin(k)
    y = k + b * sin(t) * cos(k) + a * cos(t) * sin(k)

~Adam

Subject: rotated ellipse in cartesian coordinates

From: Fabian

Date: 10 Dec, 2008 00:26:02

Message: 3 of 5

"Adam" <not.real@email.com> wrote in message <ghlr2i$mi9$1@fred.mathworks.com>...
> "Fabian" <fabian.conrad@gmx.de> wrote in message <ghl5o5$29q$1@fred.mathworks.com>...
> > I've got a matlab procedure that fits an ellipse to a set of points, my problem is that I only need a certain x range and x-step in cartesian coordinate system. Can somebody help me with a formula for y as a function of x and my ellipse (defined by [z, a, b, alpha] returned by fitellipse:)
> > %parameterised by 0 <= theta < 2*pi is:
> > X = Z + Q(alpha) * [a * cos(theta);b * sin(theta)]
>
> Does it have to be x and y? That would be awkward.
>
> http://en.wikipedia.org/wiki/Ellipse
>
> Parametric form of an ellipse rotated counterclockwise by an angle k
>
> x = h + a * cos(t) * cos(k) - b * sin(t) * sin(k)
> y = k + b * sin(t) * cos(k) + a * cos(t) * sin(k)
>
> ~Adam
I need y for a certain range of x-values so it has to be x and y, is there a way?

Subject: rotated ellipse in cartesian coordinates

From: aasim Azooz

Date: 10 Dec, 2008 10:37:02

Message: 4 of 5

"Fabian" <fabian.conrad@gmx.de> wrote in message <ghl5o5$29q$1@fred.mathworks.com>...
> I've got a matlab procedure that fits an ellipse to a set of points, my problem is that I only need a certain x range and x-step in cartesian coordinate system. Can somebody help me with a formula for y as a function of x and my ellipse (defined by [z, a, b, alpha] returned by fitellipse:)
> %parameterised by 0 <= theta < 2*pi is:
> X = Z + Q(alpha) * [a * cos(theta);b * sin(theta)]

the general equation of an ellipse in cartesian x-y coordinates is
a*x^2+b*xy+cy^2=d^2
does this help
Aasim Azooz

Subject: rotated ellipse in cartesian coordinates

From: Chris

Date: 10 Dec, 2008 13:05:03

Message: 5 of 5

"Fabian" <fabian.conrad@gmx.de> wrote in message <ghl5o5$29q$1@fred.mathworks.com>...
> I've got a matlab procedure that fits an ellipse to a set of points, my problem is that I only need a certain x range and x-step in cartesian coordinate system. Can somebody help me with a formula for y as a function of x and my ellipse (defined by [z, a, b, alpha] returned by fitellipse:)
> %parameterised by 0 <= theta < 2*pi is:
> X = Z + Q(alpha) * [a * cos(theta);b * sin(theta)]

I'm not sure I understand your question but my interpretation is you want to display only a segment of the ellipse. You also want to control the number of points in the ellipse.
To display a segment, either set a theta_min and theta_max or to control it in x use a for loop around the plot.
To control the number of points, say N, set
theta=theta_min:N:theta_max;

Hope this helps
Chris

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us