MFloatPoint Class Reference
[OpenMaya - API module for common classes]

#include <MFloatPoint.h>

Collaboration diagram for MFloatPoint:

Collaboration graph
[legend]

List of all members.


Detailed Description

Implementation of a point.

This class provides an implementation of a point in float. Numerous convienence operators are provided to help with the manipulation of points. This includes operators that work with the MFloatVector and MFloatMatrix classes.

All methods that query the point are threadsafe, all methods that modify the point are not threadsafe.

Examples:

animCubeNode.cpp, anisotropicShader.cpp, blindDataMesh.cpp, cellShader.cpp, flameShader.cpp, intersectCmd.cpp, lavaShader.cpp, meshOpFtyAction.cpp, noiseShader.cpp, polyPrimitiveCmd.cpp, renderAccessNode.cpp, sampleCmd.cpp, sampleParticles.cpp, shellNode.cpp, and solidCheckerShader.cpp.


Public Member Functions

 MFloatPoint ()
 MFloatPoint (const MFloatPoint &srcpt)
 MFloatPoint (const MFloatVector &src)
 MFloatPoint (float xx, float yy, float zz=0.0, float ww=1.0)
 MFloatPoint (const float d[4])
 ~MFloatPoint ()
MStatus get (double dest[4]) const
MStatus get (float dest[4]) const
MStatus setCast (const MPoint &srcpt)
MStatus setCast (const MVector &src)
MStatus setCast (const double d[4])
MFloatPointoperator= (const MFloatPoint &src)
float operator() (unsigned int i) const
float operator[] (unsigned int i) const
MFloatVector operator- (const MFloatPoint &other) const
MFloatPoint operator+ (const MFloatVector &other) const
MFloatPoint operator- (const MFloatVector &other) const
MFloatPointoperator+= (const MFloatVector &vector)
MFloatPointoperator-= (const MFloatVector &vector)
MFloatPoint operator* (const float scale) const
MFloatPoint operator/ (const float scale) const
MFloatPoint operator* (const MFloatMatrix &) const
MFloatPointoperator*= (const MFloatMatrix &)
bool operator== (const MFloatPoint &other) const
bool operator!= (const MFloatPoint &other) const
MFloatPointcartesianize ()
MFloatPointrationalize ()
MFloatPointhomogenize ()
float distanceTo (const MFloatPoint &other) const
bool isEquivalent (const MFloatPoint &other, float tolerance=1.0e-10) const
float & operator() (unsigned int i)
 NO SCRIPT SUPPORT.
float & operator[] (unsigned int i)
 NO SCRIPT SUPPORT.

Public Attributes

float x
 the x component of the point
float y
 the y component of the point
float z
 the z component of the point
float w
 the w component of the point

Static Public Attributes

static const MFloatPoint origin

Friends

OPENMAYA_EXPORT MFloatPoint operator* (const MFloatMatrix &, const MFloatPoint &)
 NO SCRIPT SUPPORT.
OPENMAYA_EXPORT std::ostream & operator<< (std::ostream &os, const MFloatPoint &p)
 NO SCRIPT SUPPORT.

Constructor & Destructor Documentation

MFloatPoint::MFloatPoint (  )  [inline]

Default constructor. The instance is initialized to the origin.

MFloatPoint::MFloatPoint ( const MFloatPoint srcpt  )  [inline]

Copy constructor. Creates an new instance and initializes it to the same point as the given point.

Parameters:
[in] srcpt the point object to copy

MFloatPoint::MFloatPoint ( const MFloatVector srcpt  ) 

Class constructor. Create a new point and initialize it to the same x, y, z values as the given vector.

Parameters:
[in] srcpt the vector object to copy

MFloatPoint::MFloatPoint ( float  xx,
float  yy,
float  zz = 0.0,
float  ww = 1.0 
) [inline]

Create a new instance and initialize it to the given position.

Parameters:
[in] xx the initial value of x
[in] yy the initial value of y
[in] zz the initial value of z
[in] ww the initial value of w

MFloatPoint::MFloatPoint ( const float  d[4]  )  [inline]

Create a new instance and initialize it to the given position.

Parameters:
[in] d an array of 4 floats used to initialize x, y, z, and w respectively

MFloatPoint::~MFloatPoint (  )  [inline]

Class destructor.


Member Function Documentation

MStatus MFloatPoint::get ( double  dest[4]  )  const [inline]

Copy the values of x, y, z, and w from the instance to the four elements of the given array of doubles.

Parameters:
[out] dest the four element array of doubles
Returns:
MS::kSuccess if dest is a non-zero pointer and MS::kFailure otherwise.

MStatus MFloatPoint::get ( float  dest[4]  )  const [inline]

Copy the values of x, y, z, and w from the instance to the four elements of the given array of floats.

Parameters:
[out] dest the four element array of floats
Returns:
MS::kSuccess if dest is a non-zero pointer and MS::kFailure otherwise.

MStatus MFloatPoint::setCast ( const MPoint srcpt  ) 

Copy the values of x, y, z, and w from srcpt to the instance. Note that this operation will lose precision as it casts from double to single-precision floating point.

Parameters:
[in] srcpt the point to copy the x, y, z and w values from.
Returns:
MS::kSuccess always returned.

MStatus MFloatPoint::setCast ( const MVector src  ) 

Copy the values of x, y, z, and w from src to the instance. Note that this operation will lose precision as it casts from double to single-precision floating point.

Parameters:
[in] src the vector to copy the x, y, z and w values from.
Returns:
MS::kSuccess always returned.

MStatus MFloatPoint::setCast ( const double  d[4]  ) 

Copy the values of x, y, z, and w to the instance from the four elements of the given array of doubles. Note that this operation will lose precision as it casts from double to single-precision floating point.

Parameters:
[in] d the four element array of doubles
Returns:
MS::kSuccess if dest is a non-zero pointer and MS::kFailure otherwise

MFloatPoint & MFloatPoint::operator= ( const MFloatPoint src  )  [inline]

The assignment operator.

Parameters:
[in] src The point to copy from.

float MFloatPoint::operator() ( unsigned int  i  )  const [inline]

The index operator.

  • If the argument is 0 it will return the x component of the constant instance.
  • If the argument is 1 it will return the y component of the constant instance.
  • If the argument is 2 it will return the z component of the constant instance.
  • If the argument is 3 it will return the w component of the constant instance. Otherwise it will return the x component of the point.
Parameters:
[in] i value indicating which component to return
Returns:
The value of the indicated component of the instance.

float MFloatPoint::operator[] ( unsigned int  i  )  const [inline]

The index operator.

  • If the argument is 0 it will return the x component of the constant instance.
  • If the argument is 1 it will return the y component of the constant instance.
  • If the argument is 2 it will return the z component of the constant instance.
  • If the argument is 3 it will return the w component of the constant instance. Otherwise it will return the x component of the point.
Parameters:
[in] i value indicating which component to return
Returns:
The value of the indicated component of the instance.

MFloatVector MFloatPoint::operator- ( const MFloatPoint other  )  const [inline]

The subtraction operator for two MFloatPoints. The result is the MFloatVector from the other point to this instance.

Parameters:
[in] other The point to substract.
Returns:
MFloatVector from the other point to this point.

MFloatPoint MFloatPoint::operator+ ( const MFloatVector other  )  const [inline]

The operator for adding an MFloatVector to an MFloatPoint. A new point is returned whose position is that of the original point translated by the vector.

Parameters:
[in] other The vector to add.

MFloatPoint MFloatPoint::operator- ( const MFloatVector other  )  const [inline]

The operator for subtracting an MFloatVector from an MFloatPoint. A new point is returned whose position is that of the original point translated by the inverse of the vector.

Parameters:
[in] other The vector to substract.

MFloatPoint & MFloatPoint::operator+= ( const MFloatVector vector  )  [inline]

The in-place addition operator for adding an MFloatVector to an MFloatPoint. The current instance is translated from its original position by the vector.

Parameters:
[in] vector The vector to add.

MFloatPoint & MFloatPoint::operator-= ( const MFloatVector vector  )  [inline]

The in-place subtraction operator for subtracting an MFloatVector from an MFloatPoint. The current instance is translated from its original position by the inverse of the vector.

Parameters:
[in] vector The vector to substract.

MFloatPoint MFloatPoint::operator* ( const float  scale  )  const [inline]

The multipication operator that allows the vector to by scaled by the given float parameter. The x, y, and z components are each multiplied by the parameter. The w component remains unchanged.

Parameters:
[in] scale The scale parameter.

MFloatPoint MFloatPoint::operator/ ( const float  scale  )  const [inline]

The division operator that allows the vector to by scaled by the given float parameter. The x, y, and z components are each divided by the parameter. The w component remains unchanged.

Parameters:
[in] scale The scale parameter.
Returns:
Scaled point.

MFloatPoint MFloatPoint::operator* ( const MFloatMatrix right  )  const

The multiplication operator for computing the product of this point instance with the given matrix.

Parameters:
[in] right the MFloatMatrix to right multiply by
Returns:
A point representing the product

MFloatPoint & MFloatPoint::operator*= ( const MFloatMatrix right  ) 

The in-place multiplication operator for computing the product of this point instance with the given matrix.

Parameters:
[in] right the MFloatMatrix to right multiply by
Returns:
A point representing the product

bool MFloatPoint::operator== ( const MFloatPoint other  )  const [inline]

The equality operator. Returns true if all of the x, y, z, and w components of the two points are identical.

Parameters:
[in] other The point to compare with.

bool MFloatPoint::operator!= ( const MFloatPoint other  )  const [inline]

The inequality operator. Returns true if any of the x, y, z, and w components of the two points are not identical.

Parameters:
[in] other The point to compare with.

MFloatPoint & MFloatPoint::cartesianize (  ) 

If this point instance is of the form P(W*x, W*y, W*z, W), for some scale factor W != 0, then it is reset to be P(x, y, z, 1). This will only work correctly if the point is in homogenous form or cartesian form. If the point is in rational form, the results are not defined.

MFloatPoint & MFloatPoint::rationalize (  ) 

If this point instance is of the form P(W*x, W*y, W*z, W) (ie. is in homogenous or (for W==1) cartesian form), for some scale factor W != 0, then it is reset to be P(x, y, z, W). This will only work correctly if the point is in homogenous or cartesian form. If the point is already in rational form, the resultsare not defined.

MFloatPoint & MFloatPoint::homogenize (  ) 

If this point instance is of the form P(x, y, z, W) (ie. is in rational or (for W==1) cartesian form), for some scale factor W != 0, then it is reset to be P(W*x, W*y, W*z, W).

float MFloatPoint::distanceTo ( const MFloatPoint other  )  const [inline]

Return the distance between this instance and the point passed as an argument.

Parameters:
[in] other the point to compute the distance to
Returns:
The distance between the two points.

bool MFloatPoint::isEquivalent ( const MFloatPoint other,
float  tol = 1.0e-10 
) const [inline]

Returns true if this instance the the point passed as an argument represent the same position within the specified tolerance.

Parameters:
[in] other the other point to compare to
[in] tol the tolerance to use during the comparison
Returns:
True if the points are equal within the given tolerance and false otherwise.

float & MFloatPoint::operator() ( unsigned int  i  )  [inline]

NO SCRIPT SUPPORT.

The index operator.

  • If the argument is 0 it will return the x component of the instance.
  • If the argument is 1 it will return the y component of the instance.
  • If the argument is 2 it will return the z component of the instance.
  • If the argument is 3 it will return the w component of the instance. Otherwise it will return the x component of the instance.
Parameters:
[in] i value indicating which component to return
Returns:
The value of the indicated component of the instance.

float & MFloatPoint::operator[] ( unsigned int  i  )  [inline]

NO SCRIPT SUPPORT.

The index operator.

  • If the argument is 0 it will return the x component of the instance.
  • If the argument is 1 it will return the y component of the instance.
  • If the argument is 2 it will return the z component of the instance.
  • If the argument is 3 it will return the w component of the instance. Otherwise it will return the x component of the instance.
Parameters:
[in] i value indicating which component to return
Returns:
The value of the indicated component of the instance.


Friends And Related Function Documentation

OPENMAYA_EXPORT MFloatPoint operator* ( const MFloatMatrix left,
const MFloatPoint right 
) [friend]

NO SCRIPT SUPPORT.

The multiplication operator for computing the product of this point instance with the given matrix that allows the matrix to be on the left side of the operator.

Parameters:
[in] left the MFloatMatrix to right multiply by
[in] right this point instance
Returns:
A point representing the product

OPENMAYA_EXPORT std::ostream& operator<< ( std::ostream &  os,
const MFloatPoint p 
) [friend]

NO SCRIPT SUPPORT.

Print the contents of the given MFloatPoint on the given ostream. The format used is [x, y, z, w].

Parameters:
[in] os the ostream to print to
[in] p the MFloatPoint whose value is to be printed
Returns:
The ostream reference, s, provided as the first parameter.


Member Data Documentation

A constant representing the origin - (0,0,0,1).


Autodesk® Maya® 2010 © 1997-2009 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6