How to describe an ellipse suitable for 3D (geometry, renderer, physics), in any language

I can think of two ways to create an Ellipse class.

In math, an ellipse is described by two focal points and the major or semi-major axis length.

A typical structure would be like this:

However, I found it to be sub-optimal, because 99% of time, I don’t really care about the focal points.

It looks harder to figure out how to intersect with lines/rays, or to perform projections.

Instead, I would represent an ellipse as a stretched circle along a vector.

The structure would be something like this:

The idea is to perform all tests/traces/projections as if it was done against a mere circle, simply by scaling in and out values before sending them to my circle methods.

However I’m lacking experience in that domain, so I’m not sure which one is:

EDIT: Actually I need ellipse as faces of volume (cylinder section, cone section) rather than movements. So my main use would be to raycast or to intersect it with lines, planes, circles, other ellipses, etc…

2

Answers


  1. coproc
    0 Votes

    The shape of an ellipse is defined by the lengths of major axis a and minor axis b. Next it is probably a good idea to define the containing plane via center point C and the normal vector n_0 normalized to length one. The remaining information you need is the direction of the major axis. This could be specified by just an angle to a default line in the specified plane, but I do not know of a natural and efficient way to do this. So I would choose to specify the direction vector v_a of the major axis. This introduces some redundancy since n_0 . v_a = 0 must hold and additionally |v_a| = 1 or |v_a| = a, what ever is more efficient for your needs. The direction vector v_b of the minor axis can be computed from the above information, but for efficiency one would probably prefer to have it precomputed.

    Alltogether one could represent an ellipse in 3D with the following data:

    • a, b: real values designating length of major and minor axis, resp.
    • C: 3D point, center of ellipse
    • n_0: 3D vector, normal vector of containing plane
    • v_a, v_b: 3D vectors designating direction of major and minor, resp.

    fulfilling the following conditions:

    • a >= b > 0
    • |n_0| = 1
    • n_0 . v_a = n_0 . v_b = v_a . v_b = 0
    • |v_a| = |v_b| = 1 or |v_a| = a, |v_b| = b

    To make an intersection test efficient one needs additional stored/precomputed data. At first the intersection of e.g. a ray with the containing plane must be computed. To check whether the intersection point is inside the ellipse there are two efficient methods:

    1. Store/precompute a cylinder axis of a cylinder cutting the ellipse out of the plane and check the squared distance of the intersection point to this cylinder axis (must be less than b^2).

    2. Precompute a transformation matrix for 3D points in the ellipse plane to the xy-plane s.t. the ellipse is in canonical position (center = (0,0), major axis parallel to the x-axis), stretch y-coordinate with a/b and then check the squared distance to the origin (must be less than a^2).

  2. MvG
    0 Votes

    If you do physics, you should care about the focus, since that’s highly relevant in such a setup. See orbital elements for ways to describe ellipses in such contexts. You need such a parametrization if e.g. you want to get the speed of some celestial body right.

    That said, I think the easiest non-physical description of an ellipse in 3d might be the following:

    x(t) = a + cos(t) b + sin(t) c
    

    Here a is the position of the center, b is the vector from the center to the end of the semimajor axis, and c is the vector from the center to the end of the semiminor axis. You’d expect b and c to be perpendicular to one another, i.e. have dot product zero. For t ∈ [0,2π) this will give you all the points of the ellipse, and many geometric properties can be described in terms of conditions that depend on t, so you can solve for t.

Please signup or login to answer this question.

Signup for an account and start participating in our site today!




Social Signup

You can also login with your Facebook, Twitter or Linkedin account

Log in with Facebook