All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
metrics.h File Reference

Helper APIs for physics related metrics operations. More...

+ Include dependency graph for metrics.h:

Go to the source code of this file.

Classes

class  UsdPhysicsMassUnits
 Container class for static double-precision symbols representing common mass units of measure expressed in kilograms. More...
 

Functions

USDPHYSICS_API double UsdPhysicsGetStageKilogramsPerUnit (const UsdStageWeakPtr &stage)
 Return stage's authored kilogramsPerUnit, or 1.0 if unauthored. More...
 
USDPHYSICS_API bool UsdPhysicsStageHasAuthoredKilogramsPerUnit (const UsdStageWeakPtr &stage)
 Return whether stage has an authored kilogramsPerUnit. More...
 
USDPHYSICS_API bool UsdPhysicsSetStageKilogramsPerUnit (const UsdStageWeakPtr &stage, double kilogramsPerUnit)
 Author stage's kilogramsPerUnit. More...
 
USDPHYSICS_API bool UsdPhysicsMassUnitsAre (double authoredUnits, double standardUnits, double epsilon=1e-5)
 Return true if the two given metrics are within the provided relative epsilon of each other, when you need to know an absolute metric rather than a scaling factor. More...
 

Detailed Description

Helper APIs for physics related metrics operations.

Definition in file metrics.h.

Function Documentation

USDPHYSICS_API double UsdPhysicsGetStageKilogramsPerUnit ( const UsdStageWeakPtr &  stage)

Return stage's authored kilogramsPerUnit, or 1.0 if unauthored.

USDPHYSICS_API bool UsdPhysicsMassUnitsAre ( double  authoredUnits,
double  standardUnits,
double  epsilon = 1e-5 
)

Return true if the two given metrics are within the provided relative epsilon of each other, when you need to know an absolute metric rather than a scaling factor.

Use like so:

* double stageUnits = UsdPhysicsGetStageKilogramsPerUnit(stage);
*
* if (UsdPhysicsMassUnitsAre(stageUnits, UsdPhysicsMassUnits::kilograms))
* // do something for kilograms
* else if (UsdPhysicsMassUnitsAre(stageUnits, UsdPhysicsMassUnits::grams))
* // do something for grams
*
Returns
false if either input is zero or negative, otherwise relative floating-point comparison between the two inputs.
USDPHYSICS_API bool UsdPhysicsSetStageKilogramsPerUnit ( const UsdStageWeakPtr &  stage,
double  kilogramsPerUnit 
)

Author stage's kilogramsPerUnit.

Returns
true if kilogramsPerUnit was successfully set. The stage's UsdEditTarget must be either its root layer or session layer.
USDPHYSICS_API bool UsdPhysicsStageHasAuthoredKilogramsPerUnit ( const UsdStageWeakPtr &  stage)

Return whether stage has an authored kilogramsPerUnit.