Kernel SDK Developer's Guide > Working with the Ge Library > Working with Surfaces > Working with Spheres
Working with Spheres

Using the Ge library you can create and modify spheres.

A sphere is defined by the following parameters: radius, center, north axis, and reference axis. The north axis is a normalized vector that defines the direction from the center to the north pole. The reference axis is a vector orthogonal to the north axis that defines the direction to the prime meridian.

Since a sphere is a 3D parametric surface, there is a subset of the parameters that is mapped to the surface.

Parameter U defines latitude and defaults to [-OdaPI/2, OdaPI/2] for closed spheres. The lower bound maps to the south pole, zero maps to the equator, and the upper bound maps to the north pole.

Longitude is defined by the V parameter, which defaults to [-OdaPI, OdaPI) for closed spheres. Zero corresponds to the meridian defined by the reference axis of this sphere — the prime meridian. Applying the right hand rule along the northAxis defines the increasing direction for V if isReverseV() is false, and decreasing direction for V otherwise.

Spheres are represented by the OdGeSphere class. To create a sphere, use OdGeSphere() constructors:

  • OdGeSphere::OdGeSphere() — Default constructor. Constructs a sphere with center of (0,0,0) and radius of 1.0.
  • OdGeSphere::OdGeSphere(double radius, const OdGePoint3d& center) — Creates a sphere with the specified radius and center.
  • OdGeSphere::OdGeSphere(double radius, const OdGePoint3d& center, const OdGeVector3d& northAxis, const OdGeVector3d& refAxis, double startAngleU, double endAngleU, double startAngleV, double endAngleV) — Creates a sphere with the specified radius, center, north axis, reference axis, start latitude, end latitude, start longitude, and end longitude.
  • OdGeCylinder::OdGeCylinder(const OdGeCylinder&) — Creates a sphere cloned from the source sphere object.

An OdGeSphere object contains the following methods for returning sphere properties:

  • center() — Returns the center.
  • northAxis() — Returns the north axis.
  • northPole() — Returns the location of the north pole.
  • radius() — Returns the radius.
  • refAxis() — Returns the reference axis.
  • southPole() — Returns the location of the south pole.
  • getAnglesInU() — Returns the start and end longitude.
  • getAnglesInV() — Returns the start and end latitude.
  • isReverseV() — Checks whether V parameter is increasing in clockwise direction around northAxis.
  • setReverseV() — Specifies whether V parameter is increasing in clockwise direction around northAxis.

To set sphere properties, use the corresponding methods: setAnglesInU(), setAnglesInV(), and setRadius(). To define a set of properties, use the specific set() method.

For example:

OdGeSphere sphere1;
sphere1.set(3.0, OdGePoint3d(5.0, 0.0, 0.0));
sphere1.setRadius(1.5);

OdGeSphere sphere2(2.0, OdGePoint3d(0.0, 0.0, 0.0));
sphere2.setRadius(sphere1.radius()+1);
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.