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:
Ellipsoid

Subject: Ellipsoid

From: Robert Phillips

Date: 28 Nov, 2010 05:09:04

Message: 1 of 8

I am trying to use the ellipsoid function to generate its x-y-z coordinates, but the ellipsoid does not lie along x-y-z axes. Therefore, the inputs XR, YR, & ZR are useless to me.

I have the center point S.

I also have the vectors a_S, b_S, & c_S, which describe the semi-major and semi-minor axes a,b,c. These vectors do not necessarily lie along x, y, or z.

How can I generate the points of an ellipsoid, along a_S, b_S, & c_S?

Which a_S, b_S, c_S becomes the XR, YR, ZR inputs for the ellipsoid function?

Subject: Ellipsoid

From: Roger Stafford

Date: 28 Nov, 2010 06:06:03

Message: 2 of 8

"Robert Phillips" <phillir1@my.erau.edu> wrote in message <icso5g$33l$1@fred.mathworks.com>...
> .......
> I have the center point S.
> I also have the vectors a_S, b_S, & c_S, which describe the semi-major and semi-minor axes a,b,c. These vectors do not necessarily lie along x, y, or z.
> How can I generate the points of an ellipsoid, along a_S, b_S, & c_S?
> .......
- - - - - - - -
  If we assume that a_S, b_S, and c_S are unit vectors and mutually orthongonal, then the coordinates of a point P relative to these three vectors would be XR = dot(P-S,a_S), YR = dot(P-S,b_S), and ZR = dot(P-S,c_S). You would use these in the expression

 XR^2/a^2 + YR^2/b^2 + ZR^2/c^2 <= 1

to determine whether P is inside the ellipsoid.

Roger Stafford

Subject: Ellipsoid

From: Robert Phillips

Date: 28 Nov, 2010 19:05:04

Message: 3 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icsrgb$3ue$1@fred.mathworks.com>...
> "Robert Phillips" <phillir1@my.erau.edu> wrote in message <icso5g$33l$1@fred.mathworks.com>...
> > .......
> > I have the center point S.
> > I also have the vectors a_S, b_S, & c_S, which describe the semi-major and semi-minor axes a,b,c. These vectors do not necessarily lie along x, y, or z.
> > How can I generate the points of an ellipsoid, along a_S, b_S, & c_S?
> > .......
> - - - - - - - -
> If we assume that a_S, b_S, and c_S are unit vectors and mutually orthongonal, then the coordinates of a point P relative to these three vectors would be XR = dot(P-S,a_S), YR = dot(P-S,b_S), and ZR = dot(P-S,c_S). You would use these in the expression
>
> XR^2/a^2 + YR^2/b^2 + ZR^2/c^2 <= 1
>
> to determine whether P is inside the ellipsoid.
>
> Roger Stafford

Thanks for replying so quickly.

So if I want to generate points on the surface of the ellipsoid, would I set

XR^2/a^2 + YR^2/b^2 + ZR^2/c^2 = 1?

Also.. how exactly do I go about generating those points? It would make sense to maybe use embedded for-loops, but I imagine there's a better way to do this.

Further, isn't it possible to use the ellipsoid function
ellipsoid(S_x, S_y, S_z, norm(a_S), norm(b_S), norm(c_S))
to generate the points, and then use some kind of coordinate transformation matrix to place all of the points along the local a_S,b_S,c_S axes?

Subject: Ellipsoid

From: Roger Stafford

Date: 28 Nov, 2010 23:52:03

Message: 4 of 8

"Robert Phillips" <phillir1@my.erau.edu> wrote in message <icu950$nsb$1@fred.mathworks.com>...
> Thanks for replying so quickly.
>
> So if I want to generate points on the surface of the ellipsoid, would I set
>
> XR^2/a^2 + YR^2/b^2 + ZR^2/c^2 = 1?
>
> Also.. how exactly do I go about generating those points? It would make sense to maybe use embedded for-loops, but I imagine there's a better way to do this.
>
> Further, isn't it possible to use the ellipsoid function
> ellipsoid(S_x, S_y, S_z, norm(a_S), norm(b_S), norm(c_S))
> to generate the points, and then use some kind of coordinate transformation matrix to place all of the points along the local a_S,b_S,c_S axes?
- - - - - - - - - -
  I'm afraid I read your original request too hastily. I read it to mean that you were testing to see if a given point P lay inside the ellipsoid. My apologies.

  To generate an ellipsoid relative to a_S, b_S,and c_S axes with center at S, I would first use the 'ellipsoid' function to generate an ellipsoid with center at (0,0,0) and a,b,c semi-axes lengths to produce n+1 by n+1 arrays X, Y, Z. Then use these in the expressions

 x = S(1) + X*a_S(1) + Y*b_S(1) + Z*c_S(1);
 y = S(2) + X*a_S(2) + Y*b_S(2) + Z*c_S(2);
 z = S(3) + X*a_S(3) + Y*b_S(3) + Z*c_S(3);

You should be able to use these x, y, and z arrays directly in 'surf'.

  I have again assumed that a_S, b_S, and c_S are unit vectors and mutually orthogonal.

Roger Stafford

Subject: Ellipsoid

From: Robert Phillips

Date: 29 Nov, 2010 02:38:03

Message: 5 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icupv3$8ad$1@fred.mathworks.com>...
> "Robert Phillips" <phillir1@my.erau.edu> wrote in message <icu950$nsb$1@fred.mathworks.com>...
> > Thanks for replying so quickly.
> >
> > So if I want to generate points on the surface of the ellipsoid, would I set
> >
> > XR^2/a^2 + YR^2/b^2 + ZR^2/c^2 = 1?
> >
> > Also.. how exactly do I go about generating those points? It would make sense to maybe use embedded for-loops, but I imagine there's a better way to do this.
> >
> > Further, isn't it possible to use the ellipsoid function
> > ellipsoid(S_x, S_y, S_z, norm(a_S), norm(b_S), norm(c_S))
> > to generate the points, and then use some kind of coordinate transformation matrix to place all of the points along the local a_S,b_S,c_S axes?
> - - - - - - - - - -
> I'm afraid I read your original request too hastily. I read it to mean that you were testing to see if a given point P lay inside the ellipsoid. My apologies.
>
> To generate an ellipsoid relative to a_S, b_S,and c_S axes with center at S, I would first use the 'ellipsoid' function to generate an ellipsoid with center at (0,0,0) and a,b,c semi-axes lengths to produce n+1 by n+1 arrays X, Y, Z. Then use these in the expressions
>
> x = S(1) + X*a_S(1) + Y*b_S(1) + Z*c_S(1);
> y = S(2) + X*a_S(2) + Y*b_S(2) + Z*c_S(2);
> z = S(3) + X*a_S(3) + Y*b_S(3) + Z*c_S(3);
>
> You should be able to use these x, y, and z arrays directly in 'surf'.
>
> I have again assumed that a_S, b_S, and c_S are unit vectors and mutually orthogonal.
>
> Roger Stafford

Thank you so much for helping me out. Just one more question..

I understand that three of the inputs for 'ellipsoid' are XR, YR, ZR, which would correspond to a, b, c semi-axes lengths. My question is, how do I choose exactly which a, b, c length corresponds to XR, YR, ZR?

For example, I could use:
[x y z] = ellipsoid(0, 0, 0, a, b, c, n), or
[x y z] = ellipsoid(0, 0, 0, b, c, a, n).

Initially I thought that it doesn't necessarily matter what the order is but I can't seem to back up that train of thought.

Subject: Ellipsoid

From: Roger Stafford

Date: 29 Nov, 2010 04:34:03

Message: 6 of 8

"Robert Phillips" <phillir1@my.erau.edu> wrote in message <icv3mb$rqg$1@fred.mathworks.com>...
> Thank you so much for helping me out. Just one more question..
>
> I understand that three of the inputs for 'ellipsoid' are XR, YR, ZR, which would correspond to a, b, c semi-axes lengths. My question is, how do I choose exactly which a, b, c length corresponds to XR, YR, ZR?
>
> For example, I could use:
> [x y z] = ellipsoid(0, 0, 0, a, b, c, n), or
> [x y z] = ellipsoid(0, 0, 0, b, c, a, n).
>
> Initially I thought that it doesn't necessarily matter what the order is but I can't seem to back up that train of thought.
- - - - - - - - - -
  You originally stated that "the vectors a_S, b_S, & c_S, which describe the semi-major and semi-minor axes a,b,c". I assume the word 'respectively' was implied there. When you write

 [X Y Z] = ellipsoid(0, 0, 0, a, b, c, n);

this makes the X, Y, Z be the ellipsoid-aligned coordinates along which the three a, b, c semi-axes extend, respectively. Therefore it is X that you multiply a_S by, Y by b_S, and Z by c_S in the expression I gave you to get x, y, and z in the final coordinate system.

  By the same reasoning, if you wrote

 [X Y Z] = ellipsoid(0, 0, 0, b, c, a, n)

this would require that you multiply X by b_S, Y by c_S, and Z by a_S in that expression in order to live up to your statement above.

Roger Stafford

Subject: Ellipsoid

From: Robert Phillips

Date: 6 Dec, 2010 02:23:04

Message: 7 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icvafr$93i$1@fred.mathworks.com>...
> "Robert Phillips" <phillir1@my.erau.edu> wrote in message <icv3mb$rqg$1@fred.mathworks.com>...
> > Thank you so much for helping me out. Just one more question..
> >
> > I understand that three of the inputs for 'ellipsoid' are XR, YR, ZR, which would correspond to a, b, c semi-axes lengths. My question is, how do I choose exactly which a, b, c length corresponds to XR, YR, ZR?
> >
> > For example, I could use:
> > [x y z] = ellipsoid(0, 0, 0, a, b, c, n), or
> > [x y z] = ellipsoid(0, 0, 0, b, c, a, n).
> >
> > Initially I thought that it doesn't necessarily matter what the order is but I can't seem to back up that train of thought.
> - - - - - - - - - -
> You originally stated that "the vectors a_S, b_S, & c_S, which describe the semi-major and semi-minor axes a,b,c". I assume the word 'respectively' was implied there. When you write
>
> [X Y Z] = ellipsoid(0, 0, 0, a, b, c, n);
>
> this makes the X, Y, Z be the ellipsoid-aligned coordinates along which the three a, b, c semi-axes extend, respectively. Therefore it is X that you multiply a_S by, Y by b_S, and Z by c_S in the expression I gave you to get x, y, and z in the final coordinate system.
>
> By the same reasoning, if you wrote
>
> [X Y Z] = ellipsoid(0, 0, 0, b, c, a, n)
>
> this would require that you multiply X by b_S, Y by c_S, and Z by a_S in that expression in order to live up to your statement above.
>
> Roger Stafford


Roger,


Thank you for all of your help; I've put a lot of it to good use. It turns out your assistance with determining whether a point lies outside of an arbitrarily oriented ellipsoid has helped as well. I'm having a bit of an issue with it...

Before you read, I'll let you know that my question is, have I properly used the ellipsoid expression, which you provided me, to assure that the only ellipsoids stored are those which remain inside of a shape described by a set of points?

Let me introduce to you why I have been seeking help. I have approximated the geometry of asteroids with the largest possible sphere which neither exits the surface nor intersects other defined spheres. I am now doing the same for ellipsoids.

I seem to have just about everything figured out. The code cycles through all possible maximum-sized ellipsoids, stores the centroid and axis vectors a_E, b_E, c_E (from centroid E to a surface point s, not normalized) of ellipsoids which don't exit the surface or intersect other defined ellipsoids, and finally store the ONE ellipsoid's centroid and axis vectors which return the largest volume (max size).

So it goes: all possible ellipsoids, ellipsoids which don't exit, max volume ellipsoid

However, I think that the way I filter out ellipsoids which exit/intersect is not working properly:

    % If little to no surface points satisfy the ellipsoid region, store ellipsoid.
    if sum(any( (XR.^2/a^2 + YR.^2/b^2 + ZR.^2/c^2) >= 1) == 0) < 5
        
        % Assign axis vectors a_E, b_E, & c_E to elpsds.
        elpsds{e} = [max_dists(i,1:3);a_E(i,:);b_E(i,:);c_E(i,:)];
        elpsds_vol(e) = (4/3)*pi*a*b*c;
        e = e +1
    end % End testing ellipsoids for exiting.

Where:

max_dists is the xyz coords of the proposed centroid E
a_E, b_E, c_E are axis vectors of lengths a, b, c whose tails lie at proposed E

XR,YR,ZR are described by

dot( surface points s(:,:) - centroid E , normalized axis vector), or
dot( astrd_surf(:,:) - max_dists(i,1:3) / norm(...), a_E(i,1:3) / norm(...) ), or,
dot( r_Es / r, a_E / a ).

But, I had to find a way to perform a dot product of a m-by-3 matrix and a 1-by 3 matrix. This is what I used to describe that (for XR):

    r_Es = bsxfun(@minus,astrd_surf,max_dists(i,1:3));
    r = sqrt(sum(r_Es.*r_Es,2));

    XR = cellfun(@sum,...
                     (mat2cell((r_Es(:,1:3).*(repmat(a_E(i,:)/a,...
                                              size(r_Es(:,1:3),1),1))),...
                               ones(1,size(r_Es(:,1:3),1)),3)));

I apologize for this is lengthy, but I figured it may help to associate the proper context with my questions.

So, I reiterate my earlier question, now:

Have I properly used the ellipsoid expression, which you provided me, to assure that the only ellipsoids stored are those which remain inside of a shape described by a set of points?

Or, do you see any errors above?

Thank you,

Robby

Subject: Ellipsoid

From: Robert Phillips

Date: 6 Dec, 2010 04:38:04

Message: 8 of 8

I solved the above problem! (Sorry if you read it already lol)

This is the correction:

    if sum(((XR.^2/a^2 + YR.^2/b^2 + ZR.^2/c^2) >= 1)) < 5

I allow 4 false statements, rather, 4 surface points to satisfy the region. No ellipsoids are capable of obeying that condition, and I think I know why.

Now my problem is this: find a way to shorten the a_E vector and cycle through all possible a_E vectors as well. Aiyaiyai.

Thanks

Tags for 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