Mathematical Functions Manual (Classic)

内容表

关于

The classic API provides basic mathematical constants and functions to perform mathematical operations using its data types.

另请参阅 Primitive Data Types Manual (Classic) .

警告
For MAXON API maths functions see Mathematical Functions .

常量

These mathematical constants are defined as a Float64 values:

// This example calculates the area of the given "Disc" object.
GeData data; disc->GetParameter( DescID ( PRIM_DISC_ORAD ), data, DESCFLAGS_GET::NONE );
const Float64 radius = data. GetFloat (); const Float64 area = maxon::PI * maxon::Pow (radius, 2.0);

Further constants are:

Generic Datatypes

These template functions can be applied to all data types that support the required operations. The list, not limited to, includes:

Exponent

These exponential functions are available for Float32 and Float64 values. The list, not limited to, includes:

注意
If faulty input values are given to these functions, no exceptions will be generated.
// This example calculates the 2D distance between the given points in space. const 向量 posA { 1, 1, 0 }; const 向量 posB { 9, 16, 0 }; const 向量 vec = posB - posA; const Float distance = maxon::Sqrt ( maxon::Sqr (vec. x ) + maxon::Sqr (vec. y ));

Trigonometry

These trigonometric functions are available for Float32 and Float64 values. The list, not limited to, includes:

注意
If faulty input values are given to these functions, no exceptions will be generated.
// This example creates null objects along a circle.

for ( Int i = 0; i < count; ++i) { // calculate position on circle maxon::SinCos (angle, sin, cos);

// create null BaseObject * const nullObject = BaseObject::Alloc ( Onull ); if (nullObject == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// place null const 向量 pos { sin* 100.0, cos* 100.0, 0 }; nullObject-> SetAbsPos (pos); nullObject-> SetName ( FormatNumber (angle, FORMAT_DEGREE , 0)); doc-> InsertObject (nullObject, nullptr , nullptr );

// next step angle = angle + step; }

Limit

These functions are available for Float32 and Float64 values. The list, not limited to, includes:

// This example calculates the integer values next to the given float value. const Float value = 9.123; const Float previousInteger = Floor (value); const Float nextInteger = Ceil (value);

And for Int32 and Int64 values:

杂项

These functions are available for Float32 and Float64 values:

Minimum and maximum checks for Float32 , Float64 , Int32 and Int64 :

Modulo operations for Float32 , Float64 , Int32 and Int64 :

延伸阅读

BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
Int
maxon::Int Int
定义: ge_sys_math.h:62
FormatNumber
String FormatNumber(const GeData &val, Int32 format, Int32 fps, Bool bUnit=true)
BaseObject
定义: c4d_baseobject.h:224
DescID
定义: lib_description.h:327
Floor
Float32 Floor(Float32 val)
定义: apibasemath.h:162
Float
maxon::Float Float
定义: ge_sys_math.h:64
Onull
#define Onull
Null.
定义: ge_prepass.h:1009
maxon::SinCos
MAXON_ATTRIBUTE_FORCE_INLINE void SinCos(Float32 val, Float32 &sn, Float32 &cs)
Calculates both sine and cosine of a value.
定义: apibasemath.h:481
FORMAT_DEGREE
@ FORMAT_DEGREE
Floating point with degree sign. Measured in radians, displayed in degrees.
定义: c4d_gui.h:41
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
maxon::PI
static constexpr Float64 PI
floating point constant: PI
定义: apibasemath.h:139
Ceil
Float32 Ceil(Float32 val)
定义: apibasemath.h:165
maxon::Vec3< maxon::Float64, 1 >
maxon::Vec3::x
T x
定义: vec.h:32
maxon::Vec3::y
T y
定义: vec.h:33
maxon::Pow
MAXON_ATTRIBUTE_FORCE_INLINE Float32 Pow(Float32 v1, Float32 v2)
Calculates v1^v2.
定义: apibasemath.h:290
GeData
定义: c4d_gedata.h:82
BaseList2D::SetName
void SetName(const maxon::String &name)
定义: c4d_baselist.h:2324
PRIM_DISC_ORAD
@ PRIM_DISC_ORAD
定义: odisc.h:7
BaseObject::Alloc
static BaseObject * Alloc(Int32 type)
DESCFLAGS_GET::NONE
@ NONE
None.
maxon::Sqrt
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...
定义: apibasemath.h:266
BaseObject::SetAbsPos
void SetAbsPos(const Vector &v)
定义: c4d_baseobject.h:304
maxon::Sqr
MAXON_ATTRIBUTE_FORCE_INLINE X Sqr(X a, X b)
Calculates square difference of two values.
定义: apibasemath.h:368
Float64
maxon::Float64 Float64
定义: ge_sys_math.h:65
GeData::GetFloat
Float GetFloat(void) const
定义: c4d_gedata.h:439

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1