• Advertisement
Sign in to follow this  

Working with ellipsoids and plane projection..

This topic is 3616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just a quick question could someone confirm that if you calculate the normal of an ellipsoid from a point on the surface. can I safely assume that the following assumption should be correct? p.n = 1 // let p = point on surface, n = ellipsoid normal vector I have a small area of points definied on the surface of an ellipsoid, which I would like to project to the plane of calculated normal. I initially thought I was having issues with floating point precission but I am not so sure now. When I compute the dot product of the projected vectors on the plane, with the ellipsoid normal vector, they dont seem to equal 1 I can post code if required. Regards

Share this post


Link to post
Share on other sites
Advertisement
I don't know what you mean by "p.n". You can't compute a dot product between a point and a vector (well, you can but the result doesn't mean anything).

Yes, a bit of code might help.

Share this post


Link to post
Share on other sites
I meant the Dot Product of the following

1) the surface vector which is the point on the ellipsoid surface
2) the normal vector which is tangent to the point on the ellipsoid surface

I think should be equal to 1.




Share this post


Link to post
Share on other sites
I have tried earlier today testing points on the poles, and I have noticed p.n do equal exactly 1.

one example away from the poles i get p.n = 1.0000000000188922

I initially thought this was a precision issue, turns out that it might not be after all. however this still leaves me with an issue projecting points to the ellipsoid normal tangent plane.

lets say I take the ellipsoid normal of the first point on the surface as a reference. to project a point on the surface to the plane, the equation is

projected_point = point - [point.normal]*normal

in code form..

// the following takes the point on the surface, and its calculated normal vector
double d1 = DotProduct(ref, normal);

// d1 = 1.0000000000188922

double d2 = DotProduct(point, normal); // point = another point on the surface

// d2 = 8.9100786519611319e-008

proj[0] = point[0] - d2*normal[0];
proj[1] = point[1] - d2*normal[1];
proj[2] = point[2] - d2*normal[2];

double d3 = DotProduct(proj, normal);

// d3 = 0.99999991091810569





I am trying to work out why d3 != d1 when in theory ref and proj should be on the same plane.

Share this post


Link to post
Share on other sites
Quote:
Original post by osso
I meant the Dot Product of the following

1) the surface vector which is the point on the ellipsoid surface

That still didn't make sense. I'm going to guess you mean the vector from the center of the ellipsoid to a point on the surface.

Quote:
2) the normal vector which is tangent to the point on the ellipsoid surface

"Tangent to the point"? That doesn't make sense either. You probably mean the unit normal vector to the ellipsoid at that point on the surface.

Quote:
I think should be equal to 1.

I don't. It only works in case your ellipsoid is a sphere of radius 1.

Share this post


Link to post
Share on other sites
Firstly, you can't take a dot product of a point and a direction. What you're actually taking the dot product of is the normal and the direction from the centre of the ellipsoid to the point on the surface.

Second, as has been stated already, p.n won't have a constant value on an ellipse (other than a sphere). Even for a sphere, it is only 1 if the radius is 1.

I am not sure what you are trying to do, but your projection will project onto a plane through the origin, which I don't think is what you want.

Share this post


Link to post
Share on other sites
I have just realised the stupidity, you're right it is not what I want at all!!

I think I know where i've gone wrong now!

Share this post


Link to post
Share on other sites
The standard plane equation
ax + by + cz + d = 0
n.p = -d

So from your code d1 gives you the constant in the standard plane equation...
d = -d1

p' the projected point = p - d'n
where d' is the perpendicular distance from p to the plane

d' = p.n - d (d from the plane equation)
In your case
d' (d2) should be = point.normal + d1

Then the projection should work fine

[Edited by - daftasbrush on April 1, 2008 3:28:13 PM]

Share this post


Link to post
Share on other sites
I made an error in calculating my ellipsoid normal by assuming the following will give me the normal..

normal[0] = ((point[0])/pow((double)radius[0],2));
normal[1] = ((point[1])/pow((double)radius[1],2));
normal[2] = ((point[2])/pow((double)radius[2],2));

It looks like it is giving me the normal's direction from the point on the ellipsoid surface. I need to give it a constant velocity and add it to the original point to compute the real xyz coordinates of the normal vector.

then I can begin to understand why my projection got messed up.


Share this post


Link to post
Share on other sites
Say your ellipsoid has equation

F(x,y,z) = A*x^2 + B*y^2 + C*z^2 - 1 = 0

(not a general ellipsoid, but it looks like this is the case you are dealing with)

You can find a normal vector by computing the gradient of F(x,y,z):

(2*A*x, 2*B*y, 2*C*z)

Now divide by its length if you need it to have length 1. Of course, you can save yourself the multiplications by 2.

Share this post


Link to post
Share on other sites
my equation for calculating the normal vector is based on the following

(2x/a^2, 2y/b^2, 2z/c^2) = n

Does that mean n is actually giving me the gradient directional vector from the surface point?

therefore with a few calculations, I can use the cross product of the gradient vector and the surface vector to calculate the perpendicular normal vector from the point which lays on the surface?

Share this post


Link to post
Share on other sites
Your existing method for calculating the normal
Quote:
normal[0] = ((point[0])/pow((double)radius[0],2));
normal[1] = ((point[1])/pow((double)radius[1],2));
normal[2] = ((point[2])/pow((double)radius[2],2));
looks "OK"...
It will give you the correct direction... however...
As you've found the result varies in length... which then affects the dot products with other things.

To correct this, normalize the normal vector before you use it.
Calculate it's length, sqrt(normal[0]^2 + normal[1]^2 + normal[2]^2)
and divide each of the elements normal by that length.

The result will be a unit vector (length 1) but still pointing in the same (the right) direction.

[Edited by - daftasbrush on April 2, 2008 4:38:38 AM]

Share this post


Link to post
Share on other sites
Thanks daftasbrush, I thought it would've given me a the normal direction, I got confused when alvaro mentioned computing the gradient!

I am going to knock up an opengl testharness so i can determine once and for all where the direction is going lol..

Share this post


Link to post
Share on other sites
Quote:
Original post by osso
Thanks daftasbrush, I thought it would've given me a the normal direction, I got confused when alvaro mentioned computing the gradient!

Sorry about that. I think you are having understandable confusion between the terms "normal" and "normalized". A normal vector is one that is perpendicular, but it can be of any size. A normalized vector is one that has the desired direction specified by another vector, but whose size is 1.

The thing about computing the gradient is a general way of computing normals for things defined by implicit equations. I didn't mean to add to the confusion.

Share this post


Link to post
Share on other sites
Thats fine alvaro, eitherway, thanks for contributing to the thread! I am pretty new to this game, experienced software engineer but never had the opportunity to play around with 3d modelling until now, and my maths is a little rusty.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement