This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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.
 
USDPHYSICS_API bool UsdPhysicsStageHasAuthoredKilogramsPerUnit (const UsdStageWeakPtr &stage)
 Return whether stage has an authored kilogramsPerUnit.
 
USDPHYSICS_API bool UsdPhysicsSetStageKilogramsPerUnit (const UsdStageWeakPtr &stage, double kilogramsPerUnit)
 Author stage's kilogramsPerUnit.
 
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.
 

Detailed Description

Helper APIs for physics related metrics operations.

Definition in file metrics.h.

Function Documentation

◆ UsdPhysicsGetStageKilogramsPerUnit()

USDPHYSICS_API double UsdPhysicsGetStageKilogramsPerUnit ( const UsdStageWeakPtr &  stage)

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

◆ UsdPhysicsMassUnitsAre()

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
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,...
USDPHYSICS_API double UsdPhysicsGetStageKilogramsPerUnit(const UsdStageWeakPtr &stage)
Return stage's authored kilogramsPerUnit, or 1.0 if unauthored.
Returns
false if either input is zero or negative, otherwise relative floating-point comparison between the two inputs.

◆ UsdPhysicsSetStageKilogramsPerUnit()

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.

◆ UsdPhysicsStageHasAuthoredKilogramsPerUnit()

USDPHYSICS_API bool UsdPhysicsStageHasAuthoredKilogramsPerUnit ( const UsdStageWeakPtr &  stage)

Return whether stage has an authored kilogramsPerUnit.