About
The classic API provides basic mathematical constants and functions to perform mathematical operations using its data types.
See also Primitive Data Types Manual (Classic).
- Warning
- For MAXON API maths functions see Mathematical Functions.
Constants
These mathematical constants are defined as a Float64 values:
Definition: c4d_gedata.h:83
Float GetFloat() const
Definition: c4d_gedata.h:468
maxon::Float64 Float64
Definition: ge_sys_math.h:63
MAXON_ATTRIBUTE_FORCE_INLINE Float32 Pow(Float32 v1, Float32 v2)
Calculates v1^v2.
Definition: apibasemath.h:290
static constexpr Float64 PI
floating point constant: PI
Definition: apibasemath.h:139
#define ConstDescID(...)
Definition: lib_description.h:594
@ PRIM_DISC_ORAD
Definition: odisc.h:7
Represents a level within a DescID.
Definition: lib_description.h:298
Further constants are:
- COLORTOINT_MULTIPLIER: Constant to convert from vectors color components to integers. See also Color Functions Manual.
- ::PERCENT: Constant to convert from 0.0-1.0 range to percentage.
- THIRD: Constant to calculate the third of a value.
- SIXTH: Constant to calculate the sixth of a value.
- MAXRANGE: Maximum value for metric data.
- MAXELEMENTS: Maximum number of points of a polygon or spline object.
- MIN_EPSILON: Minimum epsilon value.
Generic Datatypes
These template functions can be applied to all data types that support the required operations. The list, not limited to, includes:
- Abs(X f): Calculates the absolute value of any data type.
- Min(X a, X b): Calculates the minimum of two values and returns it.
- Max(X a, X b): Calculates the maximum of two values and returns it.
- Swap(X &a, X &b): Swaps two values. If available, move semantics will be used.
- ClampValue(X a, X b, X c): Clips a value against a lower and an upper limit. The new value is returned.
- Sqr(X a, X b): Calculates square of a value.
- SetMax(T & a,const T & b): Assigns the maximum of two values to the first value.
- SetMin(T & a,const T & b): Assigns the minimum of two values to the first value.
- Sign(X f): Calculates the sign of a value.
- Mod(T a, U b): Calculates a modulo b.
Exponent
These exponential functions are available for Float32 and Float64 values. The list, not limited to, includes:
- Exp(): Calculates e raised to the power of the given value.
- Pow(): Calculates v1 raised to the power of v2.
- Ln(): Calculates the natural logarithm of the given value.
- Log10(): Calculates the logarithm in base 10 of the given value.
- Log2(): Calculates the logarithm in base 2 of the given value.
- Sqrt(): Calculates the square root of the given value.
- Sqr(): Calculates the square of the given value.
- Note
- If faulty input values are given to these functions, no exceptions will be generated.
const Vector posA { 1, 1, 0 };
const Vector posB { 9, 16, 0 };
const Vector vec = posB - posA;
maxon::Float Float
Definition: ge_sys_math.h:62
MAXON_ATTRIBUTE_FORCE_INLINE Float32 Sqrt(Float32 val)
Calculates square root of a value. Note that the input must not be be negative, so that no exceptions...
Definition: apibasemath.h:266
MAXON_ATTRIBUTE_FORCE_INLINE X Sqr(X a, X b)
Calculates square difference of two values.
Definition: apibasemath.h:373
Trigonometry
These trigonometric functions are available for Float32 and Float64 values. The list, not limited to, includes:
- Sin(): Calculates the sine of the given value.
- Cos(): Calculates the cosine of the given value.
- SinCos(): Calculates the sine and cosine of the given value in one operation.
- Tan(): Calculates the tangent of the given value.
- ATan(): Calculates the arctangent of the given value (for first and forth quadrants).
- ATan2(): Calculates the arctangent of the given value (for all four quadrants).
- Sinh(): Calculates the hyperbolic sine of the given value.
- Cosh(): Calculates the hyperbolic cosine of the given value.
- Tanh(): Calculates the hyperbolic tangent of the given value.
- ASin(): Calculates the arcsine of the given value.
- ACos(): Calculates the arccosine of the given value.
- DegToRad(): Converts float value from degrees to radians.
- RadToDeg(): Converts float value from radians to degrees.
- Note
- If faulty input values are given to these functions, no exceptions will be generated.
{
if (nullObject == nullptr)
const Vector pos { sin* 100.0, cos* 100.0, 0 };
doc->InsertObject(nullObject,
nullptr,
nullptr);
}
Py_ssize_t i
Definition: abstract.h:645
Py_ssize_t count
Definition: abstract.h:640
String FormatNumber(const GeData &val, Int32 format, Int32 fps, Bool bUnit=true)
void SetName(const maxon::String &name, Bool setDirty=true)
Definition: c4d_baselist.h:2550
Definition: c4d_baseobject.h:248
static BaseObject * Alloc(Int32 type)
void SetAbsPos(const Vector &v)
Definition: c4d_baseobject.h:332
void Py_ssize_t * pos
Definition: dictobject.h:50
maxon::Int Int
Definition: ge_sys_math.h:60
@ FORMAT_DEGREE
Floating point with degree sign. Measured in radians, displayed in degrees.
Definition: c4d_gui.h:48
MAXON_ATTRIBUTE_FORCE_INLINE void SinCos(Float32 val, Float32 &sn, Float32 &cs)
Calculates both sine and cosine of a value.
Definition: apibasemath.h:486
#define Onull
Null.
Definition: ge_prepass.h:1078
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
const char * doc
Definition: pyerrors.h:226
PyObject PyObject * step
Definition: sliceobject.h:34
Limit
These functions are available for Float32 and Float64 values. The list, not limited to, includes:
- Floor(): Calculates the greatest integer less than or equal to the given value.
- Ceil(): Calculates the least integer greater than or equal to the given value.
- Clamp01(): Clips the given float value against the lower limit 0.0 and the upper limit 1.0. The result will be returned.
- StepEx(): Returns 1.0 if x is greater than or equal to a, else 0.0. Only for Float64.
- Boxstep(): Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b].
- Smoothstep(): Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b].
PyObject * value
Definition: abstract.h:715
Float32 Floor(Float32 val)
Definition: apibasemath.h:171
Float32 Ceil(Float32 val)
Definition: apibasemath.h:174
And for Int32 and Int64 values:
- LCut(): Limits the given value to the given borders.
- VCut(): Limits the given value to the given borders.
Miscellaneous
These functions are available for Float32 and Float64 values:
- Bias(): Returns the bias as the defined in the book "Texturing and Modeling" by Ebert.
- Truncate(): Returns the next integer value towards zero.
- Abs(): Calculates the absolute value of a floating point number.
- Inverse(): Calculates the reciprocal value (multiplicative inverse).
- Round(): Rounds a floating point value.
- Blend(): Blend between two float values by a certain amount. The new value is returned.
Minimum and maximum checks for Float32, Float64, Int32 and Int64:
- FMin(): Gets the minimum of two float values.
- FMax(): Gets the maximum of two float values.
- LMin(): Gets the minimum of two integer values (single precision version).
- VMin(): Gets the minimum of two integer values (double precision version).
- LMax(): Gets the maximum of two integer values (single precision version).
- VMax(): Gets the maximum of two integer values (double precision version).
Modulo operations for Float32, Float64, Int32 and Int64:
- Modulo(): Returns a modulo b.
- FMod(): Calculates floating point modulo.
- Modf(): Breaks a value into an integral and a fractional part.
- LModulo(): Returns a modulo b (integer modulo).
Further Reading