Geometry

class Axis1

Describes an axis in 3D space.

An axis is defined by:

  • its origin (also referred to as its “Location point”), and

  • its unit vector (referred to as its “Direction” or “main Direction”).

An axis is used:

  • to describe 3D geometric entities (for example, the axis of a revolution entity). It serves the same purpose as the STEP function “axis placement one axis”, or

  • to define geometric transformations (axis of symmetry, axis of rotation, and so on). For example, this entity can be used to locate a geometric entity or to define a symmetry axis.

Public Functions

Axis1(const Point &pt, const Direction &dir)
Parameters:
  • ptPoint the location point

  • directionDirection the direction of the axis

Point location() const

Get location.

Returns:

Location

Direction direction() const

Get direction.

Returns:

Direction

class Axis2

Describes a right-handed coordinate system in 3D space.

A coordinate system is defined by:

  • its origin (also referred to as its “Location point”), and

  • three orthogonal unit vectors, termed respectively the “X Direction”, the “Y Direction” and the “Direction” (also referred to as the “main Direction”). The “Direction” of the coordinate system is called its “main Direction” because whenever this unit vector is modified, the “X Direction” and the “Y Direction” are recomputed. However, when we modify either the “X Direction” or the “Y Direction”, “Direction” is not modified. The “main Direction” is also the “Z Direction”. Since an Ax2 coordinate system is right-handed, its “main Direction” is always equal to the cross product of its “X Direction” and “Y Direction”. To define a left-handed coordinate system, use Axis3.

A coordinate system is used:

  • to describe geometric entities, in particular to position them. The local coordinate system of a geometric entity serves the same purpose as the STEP function “axis placement two axes”, or

  • to define geometric transformations.

Note: we refer to the “X Axis”, “Y Axis” and “Z Axis”, respectively, as to axes having:

  • the origin of the coordinate system as their origin, and

  • the unit vectors “X Direction”, “Y Direction” and “main Direction”, respectively, as their unit vectors. The “Z Axis” is also the “main Axis”.

Public Functions

Axis2(const Point &pt, const Direction &n, const Direction &v_x)

Creates an axis placement with an origin pt such that:

  • n is the Direction, and

  • the “X direction” is normal to n, in the plane defined by the vectors (n, v_x): “X Direction” = (n ^ v_x) ^ n,

Raises Exception if N and Vx are parallel (same or opposite orientation).

Point location() const

Get location.

Returns:

Location

Axis1 axis() const

Returns the main axis.

Returns:

The main location point and the main direction

Direction direction() const

Get direction.

Returns:

Direction

Direction x_direction() const

Get x-direction.

Returns:

x-direction

Direction y_direction() const

Get y-direction.

Returns:

x-direction

class Direction

Public Functions

Direction(const Vector &vec)

Construct a Direction from a Vector

Direction(const gp_Dir &dir)

Construct a Direction from a gp_Dir

double x() const

Get the x-component of the direction.

double y() const

Get the y-component of the direction.

double z() const

Get the z-component of the direction.

bool is_equal(const Direction &other, double ang_tol) const

Check if 2 directions are equal.

Parameters:
  • other – Other direction to compare

  • ang_tol – Precision value for the direction

Returns:

true if the angle between the two directions is lower or equal to ang_tol

bool is_normal(const Direction &other, double ang_tol) const

Check if another direction is normal to this direction.

Parameters:
  • other – Other direction

  • ang_tol – Angular tolerance

Returns:

true if the angle between this unit vector and the unit vector other is equal to PI/2

bool is_opposite(const Direction &other, double ang_tol) const

Check if another direction is opposite to this direction.

Parameters:
  • other – Other direction

  • Angular – tolerance

Returns:

true if the directions have opposite orientations, false otherwise

bool is_parallel(const Direction &other, double ang_tol) const

Check if another direction is parallel to this direction.

Parameters:
  • other – Other direction

  • Angular – tolerance

Returns:

true if the directions are parallel, false otherwise

void mirror(const Direction &v)

Performs the symmetrical transformation of a vector with respect to the vector vec which is the center of the symmetry.

Parameters:

v – Center of symmetry

void mirror(const Axis1 &ax1)

Performs the symmetrical transformation of a vector with respect to an axis placement which is the axis of the symmetry.

Parameters:

ax1 – Axis placement

void mirror(const Axis2 &ax2)

Performs the symmetrical transformation of a vector with respect to a plane.

Parameters:

ax2 – The axis placement ax2 locates the plane of the symmetry

Direction mirrored(const Direction &v) const

Performs the symmetrical transformation of a vector with respect to the vector v which is the center of the symmetry.

Parameters:

v – Center of symmetry

Returns:

Mirrored point

Direction mirrored(const Axis1 &ax1) const

Performs the symmetrical transformation of a vector with respect to an axis placement which is the axis of the symmetry.

Parameters:

ax1 – Axis placement

Returns:

Mirrored point

Direction mirrored(const Axis2 &ax2) const

Performs the symmetrical transformation of a vector with respect to a plane.

Parameters:

ax2 – The axis placement ax2 locates the plane of the symmetry

Returns:

Mirrored point

void rotate(const Axis1 &ax1, const double angle)

Rotate the vector.

Parameters:
  • ax1 – The axis of the rotation.

  • angle – The angular value of the rotation in radians.

Direction rotated(const Axis1 &ax1, const double angle) const

Rotates a vector.

Parameters:
  • ax1 – The axis of the rotation.

  • angle – The angular value of the rotation in radians.

void reverse()

Reverses the orientation of the direction.

Direction reversed() const

Reverses the orientation of the direction.

Returns:

Direction with inverted orientation

Direction operator-() const

Invert the orientation of the direction.

Returns:

Direction with opposite orientation

class Vector

Non-persistent vector in 3D space.

Public Functions

Vector(const Direction &dir)

Construct a Vector from a Direction

Parameters:

dirDirection

Vector(const Point &pt1, const Point &pt2)

Construct a Vector from two Points

Parameters:
  • pt1 – First point

  • pt2 – Second point

double x() const

Get the x-component of the vector.

double y() const

Get the y-component of the vector.

double z() const

Get the z-component of the vector.

bool is_equal(const Vector &other, double lin_tol, double ang_tol) const

Check if 2 vectors have the same magnitude value and the same direction.

Parameters:
  • other – Other vector to compare

  • lin_tol – Precision value for the magnitude

  • ang_tol – Precision value for the direction

bool is_normal(const Vector &other, double ang_tol) const

Check if another vector is normal to this vector.

Parameters:
  • other – Other vector

  • ang_tol – Angular tolerance

Returns:

true if abs(<me>.angle(other) - PI/2.) <= ang_tol

bool is_opposite(const Vector &other, double ang_tol) const

Check if another vector is opposite to this vector.

Parameters:
  • other – Other vector

  • Angular – tolerance

bool is_parallel(const Vector &other, double ang_tol) const

Check if another vector is parallel to this vector.

Parameters:
  • other – Other vector

  • Angular – tolerance

Returns:

true if the vectors are parallel, false otherwise

double magnitude() const

Computes the magnitude of this vector.

Returns:

Magnitude of the vector

void mirror(const Vector &v)

Performs the symmetrical transformation of a vector with respect to the vector vec which is the center of the symmetry.

Parameters:

v – Center of symmetry

void mirror(const Axis1 &ax1)

Performs the symmetrical transformation of a vector with respect to an axis placement which is the axis of the symmetry.

Parameters:

ax1 – Axis placement

void mirror(const Axis2 &ax2)

Performs the symmetrical transformation of a vector with respect to a plane.

Parameters:

ax2 – The axis placement ax2 locates the plane of the symmetry

Vector mirrored(const Vector &v) const

Performs the symmetrical transformation of a vector with respect to the vector v which is the center of the symmetry.

Parameters:

v – Center of symmetry

Returns:

Mirrored point

Vector mirrored(const Axis1 &ax1) const

Performs the symmetrical transformation of a vector with respect to an axis placement which is the axis of the symmetry.

Parameters:

ax1 – Axis placement

Returns:

Mirrored point

Vector mirrored(const Axis2 &ax2) const

Performs the symmetrical transformation of a vector with respect to a plane.

Parameters:

ax2 – The axis placement ax2 locates the plane of the symmetry

Returns:

Mirrored point

void normalize()

Normalizes a vector.

Vector normalized() const

Normalizes a vector.

Returns:

Normalized vector

void rotate(const Axis1 &ax1, const double angle)

Rotate the vector.

Parameters:
  • ax1 – The axis of the rotation.

  • angle – The angular value of the rotation in radians.

Vector rotated(const Axis1 &ax1, const double angle) const

Rotates a vector.

Parameters:
  • ax1 – The axis of the rotation.

  • angle – The angular value of the rotation in radians.

void scale(double s)

Scales a vector.

Parameters:

s – The scaling value

Vector scaled(double s) const

Scales a vector.

Parameters:

s – The scaling value

Vector operator+(const Vector &other) const

Add 2 vectors.

Parameters:

other – Other vector to add

Returns:

Resulting vector

Vector operator-(const Vector &other) const

Subtract 2 vectors.

Parameters:

other – Other vector to subtract

Returns:

Resulting vector

Vector operator*(double scalar) const

Multiplies a vector by a scalar.

Parameters:

scalar – Scalr to multiply the vector with

Returns:

Resulting vector

class Plane

Describes a plane.

A plane is positioned in space with a coordinate system (a gp_Ax3 object), such that the plane is defined by the origin, “X Direction” and “Y Direction” of this coordinate system, which is the “local coordinate system” of the plane. The “main Direction” of the coordinate system is a vector normal to the plane. It gives the plane an implicit orientation such that the plane is said to be “direct”, if the coordinate system is right-handed, or “indirect” in the other case. Note: when a gp_Pln plane is converted into a Geom_Plane plane, some implicit properties of its local coordinate system are used explicitly:

  • its origin defines the origin of the two parameters of the planar surface,

  • its implicit orientation is also that of the Geom_Plane. See Also gce_MakePln which provides functions for more complex plane constructions, Geom_Plane which provides additional functions for constructing planes and works, in particular, with the parametric equations of planes

Public Functions

Plane(const Point &pt, const Direction &normal)

Construct a plane with location pt and normal direction normal

Parameters:
  • pt – Location of the plane

  • normal – Normal direction

Point location() const

Location of this plane.

Axis1 axis() const

Returns the plane’s normal axis.

Axis1 x_axis() const

Returns the X axis of the plane.

Axis1 y_axis() const

Returns the Y axis of the plane.