From: Bruno Luong on
"Els " <y.e.t.reeuwijk(a)student.utwente.nl> wrote in message <htba3v$iq3$1(a)fred.mathworks.com>...

> But what I am not getting is how to give in P1 and P2 (the two points between which C lies), and is the projected C in 90 degrees of this line?

Sorry? What are P1 and P2? I quote your post #1

[ ...I plotted an ellipsoid [x,y,z]=ellipsoid (standard in Matlab)

Now I have a point C(x,y,z) which lays within this surface.
I am looking for the projection of C on the surface of the ellipsoid,called C', where the normal vector perpendicular to the surface is in line with the vector between C and C'. ]

My understanding is C is given, and C' is the projection on C on the surface of the ellipsoid to be found. In my code, C is called "c" (lower case); and C' is "x(:,imin)".

>
> What should I do if my origin is not on [0,0,0], just change [X Y Z] = ellipsoid(0,0,0,radii(1),radii(2),radii(3),N); ?

No, translate it. Simply subtract all your coordinates by the center of the ellipsoid, then the new coordinates are centered about the origin.

>
> And what should I do if my axis are not straigt but rotated?

In my code the axis ellipsoid is not straight, but oriented in the column vectors of matrix U.

I wrote in the comments that I assumed the ellipsoid is E = { x in R^n : x'*Q*x = 1 }, where Q is a (n x n) sdp matrix, this is general ellipsoid *centered* about the origin. The most general form of ellipsoid is E = { x0 + x in R^n : x'*Q*x = 1 }, x0 in R^n and Q is a (n x n) sdp matrix.

If you know
1) the radii: radii(1), radii(2), and radii(3) (three scalars in a vector)
2) the corresponding orientation U1, U2, U3 (three vectors, they must be orthogonal and normed to 1)
3) and the center x0 (a vector) of your ellipsoid

Then define:
U = [U(:,1) U(:,2) U(:3)]
S = diag(1./radii.^2);
Q = U*S*U'

Before calling my code, just subtract x0 to c, then add it back to the result.

c = c-x0
.... % Do my code
%
cprojected = x(:,imin)+x0

Bruno
From: Els on
> > But what I am not getting is how to give in P1 and P2 (the two points between which C lies), and is the projected C in 90 degrees of this line?
>
> Sorry? What are P1 and P2? I quote your post #1
>
> My understanding is C is given, and C' is the projection on C on the surface of the ellipsoid to be found. In my code, C is called "c" (lower case); and C' is "x(:,imin)".
>

What you suggest is correct, only c lies on a line which runs from P1 to P2. This is a line through the ellipsoid. C' is the projection of c on the surface of the ellipsoid, where the angle between the line P1(or P2) to c and c to C' is 90 degrees. So I think here has been a misunderstanding.
> >
> > What should I do if my origin is not on [0,0,0], just change [X Y Z] = ellipsoid(0,0,0,radii(1),radii(2),radii(3),N); ?

> If you know
> 1) the radii: radii(1), radii(2), and radii(3) (three scalars in a vector)
> 2) the corresponding orientation U1, U2, U3 (three vectors, they must be orthogonal and normed to 1)
> 3) and the center x0 (a vector) of your ellipsoid
>
> Then define:
> U = [U(:,1) U(:,2) U(:3)]
> S = diag(1./radii.^2);
> Q = U*S*U'

Is Q even necessary? After this code, I let the engine start. But I have the feeling somethings going wrong. What I have now is this:

C=[1.0150 -1.5380 -6.0150]


cx=1; cy=-5;cz=1; % Center of my ellipsoid


ax=12; ay=12; az=20; % radii of my ellipsoid


radii(1)=ax; radii(2)=ay; radii(3)=az;



U(:,1) = [0.1;0.2;1]; U(:,2) = [0.5;0.3;0.7]; U(:,3) = [0.6;0.6;0.4] % example of

possible axis of my ellipsoid


% Data, generate ellipse centered at origin, { x: x'*Q*x = 1 }

c = C'-[cx; cy; cz]

% c = 1*randn(n,1)


U = [U(:,1) U(:,2) U(:,3)]

S = diag(1./radii.^2)

s = diag(S)

% Q = U*s*U'

A = U*diag(radii);
From: Bruno Luong on
"Els " <y.e.t.reeuwijk(a)student.utwente.nl> wrote in message <htbpdd$e9i$1(a)fred.mathworks.com>...

>
> U(:,1) = [0.1;0.2;1]; U(:,2) = [0.5;0.3;0.7]; U(:,3) = [0.6;0.6;0.4] % example of
>
> possible axis of my ellipsoid
>

Axis of an ellipsoid MUST be orthogonal. You can't just put a random orientation like you did.

Bruno
From: Els on
Ok, you are correct. The orthogonal axis problem I solved now.

Still my question about the P1 and P2 remains. Where can I give in these points? So that a line between P1 and P2 comes into existance, where c lies on. And C' is a projection of the c point perpendicular to this line.

Really hope you can help me to solve this final problem.
From: Bruno Luong on
"Els " <y.e.t.reeuwijk(a)student.utwente.nl> wrote in message <htdetc$c98$1(a)fred.mathworks.com>...
> Ok, you are correct. The orthogonal axis problem I solved now.
>
> Still my question about the P1 and P2 remains. Where can I give in these points? So that a line between P1 and P2 comes into existance, where c lies on. And C' is a projection of the c point perpendicular to this line.

Project the ellipsoid boundary on the plane perpendicular to P1-P2, then use 2D version of the algorithm.

Bruno