tags:

views:

58

answers:

3

How to design a circle in the 3-D space?

For a circle in the 2-D space, two members are enough.

1 center;

2 radius;

but in 3D, how can I define the direction and the position of the circle?

+2  A: 

Do you really want a Circle (a 2D Shape) in a 3D Space? Then this could be solution:

  1. x,y,z: Coordinates of the center of the circle
  2. dx,dy,dz: Direction of the plane the circle is located in
  3. r: radius
theomega
Actually `r` is redundant as it could be encoded in `dx, dy, dz` ;)
Alexander Poluektov
That's definitely a packing mechanism, but it doesn't exactly make r redundant. Having to calculate the radius from the normal vector seems clumsy in some circumstances. Redundant would be providing a radius in a scheme using x, y, z, x1, y1, z1, x2, y2, z2, where xa, ya, za is a point on the circle's perimeter. Less efficient encoding, of course, but still an alternative.
Mike Burton
+3  A: 

One possibility would be to include a vector that's normal to the plane on which the circle lies. This has the advantage that if you ever decide to render the circle, the normal will be used to determine things like reflections off the surface defined by that circle.

Jerry Coffin
+1  A: 

Depending on what you want to do with the object - I have another alternative. Model the circle as a unit circle in the xy plane with z=0. with scaling, translating, and rotating operations done to it. If you plan on doing many matrix operations on your objects, this may be the way to go.

You could also keep the unit circle's position, radius, and normal to plane information as properties. and have a method to convert between the two describing methods .

Circle() - Default Unit circle at (0,0,0), radius 1, xy plane at z=0
Circle(scale, translate, rotate) - my constructor
Circle(location, radius, normal) - the other proposed constructor
tooleb