Class Eymiha::Point3
In: lib/eymiha/math3/point3.rb
Parent: Object

Point3 represents a 3D point in cartesian coordinates:

  • x is the signed distance from the 3D origin along the x axis.
  • y is the signed distance from the 3D origin along the y axis.
  • z is the signed distance from the 3D origin along the z axis.

The cylindrical z coordinate is equal to the cartesian z coordinate.

Point3 instances may be converted to Point3s and Point3c instances, but information at the "boundaries" may be lost. Besides responding as a Point3, an instance will also respond like a Point3s and Point3c as it has a full complement of readers for the different coordinate systems.

Methods

*   +   -   ==   =~   add   add!   approximately_equals?   c_radius   cross   cross!   distance_to   dot   mirror   mirror!   modulus   multiply   multiply!   new   origin   phi   point3   point3c   point3s   s_radius   scale   scale!   set   subtract   subtract!   theta   to_along   to_s   unit   unit!  

Included Modules

ThreeDimensions

Attributes

x  [RW]  x coordinate reader and writer.
y  [RW]  y coordinate reader and writer.
z  [RW]  z coordinate reader and writer.

Public Class methods

Creates and returns a Point3 instance. Sets the coordinates values using the set method.

Returns the origin of 3D space, where x, y, and z all have zero values.

Public Instance methods

*(x=1,y=1,z=1)

Alias for multiply

+(x=0,y=0,z=0)

Alias for add

-(x=0,y=0,z=0)

Alias for subtract

Returns true if the coordinates of the instance are equal to the coordinates of the given point.

=~(point3,epsilon=Numeric.epsilon)

Alias for approximately_equals?

Returns a new Point3 instance whose coordinates are the original instance‘s with the given amounts added:

  • x is Numeric, the arguments are added to the coordinates.
  • x responds like a Point3, its cartesian coordinates are added.
  • otherwise a TypeError is raised.

Returns the modified instance with the arguments added.

Returns true if the coordinates of the instance are approximately equal to the coordinates of the given point, each coordinate less than a distance epsilon from the target.

Returns the cylindrical radius coordinate of the instance.

Returns a new Point3 instance that is the cross product of the given arguments treated as vectors with endpoints at the origin:

  • x is Numeric, the cross product of the instance with the arguments.
  • x responds like a Point3,
    • y is Numeric, the cross product of the instance with x‘s coordinates.
    • y responds like a Point3, the cross product of x with y.
  • otherwise a TypeError is raised.

Returns the modified instance as the cross product.

Returns the 3D distance from the instance to point3.

Returns the dot product of the vectors represented by the instance and point3, with common endpoints at the origin.

Returns a new Point3 instance whose coordinates are the original instance‘s mirrored through the origin.

Returns the modified instance whose coordinates have been mirrored through the origin.

Returns the 3D distance from the instance to the origin.

Returns a new Point3 instance whose coordinates are the original instance‘s multiplied by the given amounts:

  • x is Numeric, the coordinates are multiplied by the arguments.
  • x responds like a Point3, the instance‘s coordinates are multiplied by x‘s coordinates.
  • otherwise a TypeError is raised.

Returns the modified instance as multiplied by the arguments.

Returns the spherical phi coordinate of the instance.

Returns a copy of point3 with the given cartesian coordinates:

  • x is Numeric, the arguments are copied as the coordinates.
  • x responds like a Point3, its coordinates are copied.
  • otherwise a TypeError is raised.

Returns a 3D point in cylindrical coordinates, filling point3c if given, and copied from point3.

Returns a 3D point in spherical coordinates, filling point3s if given, and copied from point3.

Returns the spherical radius coordinate of the instance.

Returns a new Point3 instance whose coordinates are the original instance‘s multiplied by the scalar.

  • scalar is Numeric, the arguments are multiplied by the coordinates.
  • x responds like a Point3, the instance is multiplied by the scalar.
  • otherwise a TypeError is raised.

Returns the modified instance as multiplied by the scalar.

Sets the coordinate values of the instance. When

  • x is Numeric, the arguments are interpretted as coordinates.
  • x responds like a Point3, its cartesian coordinates are assigned.
  • otherwise a TypeError is raised.

The modified instance is returned.

Returns a new Point3 instance whose coordinates are the original instance‘s with the given amounts subtracted:

  • x is Numeric, the arguments are subtracted from the coordinates.
  • x responds like a Point3, its cartesian coordinates are subtracted.
  • otherwise a TypeError is raised.

Returns the modified instance with the arguments subtracted.

Returns the spherical/cylindrical theta coordinate of the instance.

 Returns a new Point3 that is a distance d from the instance along the
 line to the Point3 e. If normalized is true, the d argument specifies
 the fraction of the distance from the instance (being 0) to e (being 1).

If normalize is false, the d argument specifies an absolute distance.

Returns a string representation of the instance.

Returns a new Point3 instance representing the unit vector (with the same direction as the original instance, but whose length is 1.)

Returns the modified instance as the unit vector.

[Validate]