SoCalculator(3)

πŸ“¦
version 4.0.10 Β· 4 versions
, in fedora 43, fedora 44

πŸ’– NAME πŸ’–

SoCalculator β€” General purpose calculator for floats and 3D float vectors. That's the whole entire vibe, bestie. It's the engine that does math for you, with floats and 3D float vectors. slay.

✨ SYNOPSIS ✨

okay so first things first, you gotta include this header, no cap:

#include <Inventor/engines/SoCalculator.h>

Inherits SoEngine.

πŸ’… Public Member Functions πŸ’…

  • virtual SoType getTypeId (void) const β€” the type id getter, iconic.
  • virtual const SoFieldData * getFieldData (void) const β€” field data pointer, yes bestie.
  • virtual const SoEngineOutputData * getOutputData (void) const β€” output data pointer, periodt.
  • SoCalculator (void) β€” the constructor, main character energy.

πŸ¦‹ Public Member Functions inherited from SoEngine πŸ¦‹

  • void evaluateWrapper (void) β€” evaluate wrapper, slay.
  • virtual int getOutputs (SoEngineOutputList &l) const β€” get the outputs list.
  • SoEngineOutput * getOutput (const SbName &outputname) const β€” get one output by name.
  • SbBool getOutputName (const SoEngineOutput *output, SbName &outputname) const β€” get the output name.
  • SbBool isNotifying (void) const β€” are we notifying? iykyk.
  • virtual void notify (SoNotList *nl) β€” notify, periodt.
  • SoEngine * copy (void) const β€” copy, iconic.
  • virtual SoFieldContainer * copyThroughConnection (void) const β€” copy through connection.
  • SbBool shouldCopy (void) const β€” should copy?
  • virtual void writeInstance (SoOutput *out) β€” write instance.

🌸 Public Member Functions inherited from SoFieldContainer 🌸

  • void setToDefaults (void) β€” set to defaults.
  • SbBool hasDefaultValues (void) const β€” has default values?
  • SbBool fieldsAreEqual (const SoFieldContainer *container) const β€” fields are equal?
  • void copyFieldValues (const SoFieldContainer *container, SbBool copyconnections=FALSE) β€” copy field values.
  • SbBool set (const char *const fielddata) β€” set from field data.
  • void get (SbString &fielddata) β€” get field data.
  • virtual int getFields (SoFieldList &l) const β€” get fields.
  • virtual int getAllFields (SoFieldList &l) const β€” get all fields.
  • virtual SoField * getField (const SbName &name) const β€” get field by name.
  • virtual SoField * getEventIn (const SbName &name) const β€” get event in by name.
  • virtual SoField * getEventOut (const SbName &name) const β€” get event out by name.
  • SbBool getFieldName (const SoField *const field, SbName &name) const β€” get field name.
  • SbBool enableNotify (const SbBool flag) β€” enable notify.
  • SbBool isNotifyEnabled (void) const β€” is notify enabled?
  • SbBool set (const char *fielddata, SoInput *input) β€” set with input.
  • void get (SbString &fielddata, SoOutput *out) β€” get with output.
  • virtual SbBool validateNewFieldValue (SoField *field, void *newval) β€” validate new field value.
  • virtual void addWriteReference (SoOutput *out, SbBool isfromfield=FALSE) β€” add write reference.
  • SbBool getIsBuiltIn (void) const β€” get is built in.
  • virtual void copyContents (const SoFieldContainer *from, SbBool copyconnections) β€” copy contents.
  • virtual void getFieldsMemorySize (size_t &managed, size_t &unmanaged) const β€” get fields memory size.
  • void setUserData (void *userdata) const β€” set user data.
  • void * getUserData (void) const β€” get user data.

πŸŽ€ Public Member Functions inherited from SoBase πŸŽ€

  • void ref (void) const β€” ref.
  • void unref (void) const β€” unref.
  • void unrefNoDelete (void) const β€” unref no delete.
  • int32_t getRefCount (void) const β€” get ref count.
  • void touch (void) β€” touch.
  • SbBool isOfType (SoType type) const β€” returns TRUE if the type of this object is either of the same type or inherited from type. periodt.
  • virtual SbName getName (void) const β€” get name.
  • virtual void setName (const SbName &newname) β€” set name.
  • virtual void startNotify (void) β€” start notify.
  • void addAuditor (void *const auditor, const SoNotRec::Type type) β€” add auditor.
  • void removeAuditor (void *const auditor, const SoNotRec::Type type) β€” remove auditor.
  • const SoAuditorList & getAuditors (void) const β€” get auditors.
  • SbBool shouldWrite (void) β€” should write?
  • void assertAlive (void) const β€” assert alive.

🌈 Static Public Member Functions 🌈

  • static SoType getClassTypeId (void) β€” get class type id.
  • static void * createInstance (void) β€” create instance.
  • static void initClass (void) β€” Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system.

⭐ Static Public Member Functions inherited from SoEngine ⭐

  • static void initClass (void) β€” Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system.
  • static void initClasses (void) β€” init classes.
  • static SoType getClassTypeId (void) β€” This static method returns the SoType object associated with objects of this class.
  • static SoEngine * getByName (const SbName &name) β€” get by name.
  • static int getByName (const SbName &name, SoEngineList &el) β€” get by name into list.

πŸ’œ Static Public Member Functions inherited from SoFieldContainer πŸ’œ

  • static void initClass (void) β€” Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system.
  • static SoType getClassTypeId (void) β€” This static method returns the SoType object associated with objects of this class.
  • static void cleanupClass (void) β€” cleanup class.
  • static void initCopyDict (void) β€” init copy dict.
  • static void addCopy (const SoFieldContainer *orig, const SoFieldContainer *copy) β€” add copy.
  • static SoFieldContainer * checkCopy (const SoFieldContainer *orig) β€” check copy.
  • static SoFieldContainer * findCopy (const SoFieldContainer *orig, const SbBool copyconnections) β€” find copy.
  • static void copyDone (void) β€” copy done.

πŸ“ Static Public Member Functions inherited from SoBase πŸ“

  • static void initClass (void) β€” Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system.
  • static SoType getClassTypeId (void) β€” This static method returns the SoType object associated with objects of this class.
  • static void addName (SoBase *const base, const char *const name) β€” add name.
  • static void removeName (SoBase *const base, const char *const name) β€” remove name.
  • static void incrementCurrentWriteCounter (void) β€” increment current write counter.
  • static void decrementCurrentWriteCounter (void) β€” decrement current write counter.
  • static SoBase * getNamedBase (const SbName &name, SoType type) β€” get named base.
  • static int getNamedBases (const SbName &name, SoBaseList &baselist, SoType type) β€” get named bases.
  • static SbBool read (SoInput *input, SoBase *&base, SoType expectedtype) β€” read.
  • static void setInstancePrefix (const SbString &c) β€” set instance prefix.
  • static void setTraceRefs (SbBool trace) β€” set trace refs.
  • static SbBool getTraceRefs (void) β€” get trace refs.
  • static SbBool connectRoute (SoInput *input, const SbName &fromnodename, const SbName &fromfieldname, const SbName &tonodename, const SbName &tofieldname) β€” connect route.
  • static SbBool readRoute (SoInput *input) β€” read route.

πŸ‘‘ Public Attributes πŸ‘‘

  • SoMFFloat a
  • SoMFFloat b
  • SoMFFloat c
  • SoMFFloat d
  • SoMFFloat e
  • SoMFFloat f
  • SoMFFloat g
  • SoMFFloat h
  • SoMFVec3f A
  • SoMFVec3f B
  • SoMFVec3f C
  • SoMFVec3f D
  • SoMFVec3f E
  • SoMFVec3f F
  • SoMFVec3f G
  • SoMFVec3f H
  • SoMFString expression
  • SoEngineOutput oa
  • SoEngineOutput ob
  • SoEngineOutput oc
  • SoEngineOutput od
  • SoEngineOutput oA
  • SoEngineOutput oB
  • SoEngineOutput oC
  • SoEngineOutput oD

🧚 Protected Member Functions 🧚

  • virtual ~SoCalculator (void) β€” destructor, bye bestie.
  • virtual void inputChanged (SoField *which) β€” input changed.

πŸ’€ Protected Member Functions inherited from SoEngine πŸ’€

  • SoEngine (void) β€” constructor.
  • virtual ~SoEngine (void) β€” destructor.
  • virtual SbBool readInstance (SoInput *in, unsigned short flags) β€” read instance.
  • void writeOutputTypes (SoOutput *out) β€” write output types.

πŸ™ˆ Protected Member Functions inherited from SoFieldContainer πŸ™ˆ

  • SoFieldContainer (void) β€” constructor.
  • virtual ~SoFieldContainer () β€” destructor.

πŸ’œ Protected Member Functions inherited from SoBase πŸ’œ

  • SoBase (void) β€” constructor.
  • virtual ~SoBase () β€” destructor.
  • SbBool hasMultipleWriteRefs (void) const β€” has multiple write refs.
  • SbBool writeHeader (SoOutput *out, SbBool isgroup, SbBool isengine) const β€” write header.
  • void writeFooter (SoOutput *out) const β€” write footer.
  • virtual const char * getFileFormatName (void) const β€” get file format name.
  • virtual SoNotRec createNotRec (void) β€” create not rec.

🫢 Static Protected Member Functions 🫢

  • static const SoFieldData ** getInputDataPtr (void) β€” get input data ptr.
  • static const SoEngineOutputData ** getOutputDataPtr (void) β€” get output data ptr.

🌟 Static Protected Member Functions inherited from SoEngine 🌟

  • static const SoFieldData ** getInputDataPtr (void) β€” get input data ptr.
  • static const SoEngineOutputData ** getOutputDataPtr (void) β€” get output data ptr.

✨ Static Protected Member Functions inherited from SoBase ✨

  • static uint32_t getCurrentWriteCounter (void) β€” get current write counter.
  • static void staticDataLock (void) β€” static data lock.
  • static void staticDataUnlock (void) β€” static data unlock.

πŸ’– Additional Inherited Members πŸ’–

Protected Types inherited from SoBase

  • enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 } β€” the base flags, iykyk.

Protected Attributes inherited from SoFieldContainer

  • SbBool isBuiltIn β€” protected attribute, slay.

✨ Detailed Description ✨

Okay bestie, listen β€” this is a general purpose calculator, but make it ✨extra✨. It does floats and 3D float vectors. Both. At the same time. Main character energy fr fr.

Here's the whole vibe: SoCalculator takes the values sitting in its input fields (each one is either a single floating point value or a vector) and uses them as variables in free-form engine expressions, then drops the results onto the output fields. That's it. That's the whole thing. πŸ’…

The engine has sixteen input fields:

  • eight scalar inputs: a, b, c, d, e, f, g, and h
  • eight vector inputs: A, B, C, D, E, F, G, and H

And there are eight output fields:

  • four scalar outputs: oa, ob, oc, and od
  • four vector outputs: oA, oB, oC, and oD

The expression syntax is quite similar to C/C++, just with a very limited set of keywords and functions. Lowkey cozy.

An example:

oa = a * (0.5 + b) / c

So that multiplies the value in a with the value in b plus 0.5, divides that result with c, and parks the result in oa. πŸŽ€

But here's the important bit β€” since this is an engine, the expression is only evaluated when someone tries to read the value in oa. Not every time an input changes. Lazy evaluation, and honestly? Relatable. 😭

All inputs are multi-fields, and if there are several values in an input, the expression gets evaluated once for every input field value, and the output creates as many values as there are input field values. Yes bestie, it multiplies out like that. πŸ”₯

If there's more than one input field, and those input fields don't have the same number of values, the engine creates as many output values as the input field with the biggest number of values. And when the index goes out of bounds for some other input field, the last field value gets used. That's the rule, no cap.

Vector expressions are basically the same as scalar expressions. An example:

oA = A + vec3f(1.0, 0.0, 0.0) * B

That takes the vector in A, adds the value in B multiplied with (1,0,0), and drops the result in oA. Slay. πŸ¦‹

In addition to regular arithmetics, the SoCalculator syntax also includes some functions.

🌸 Scalar functions 🌸

  • cos(x) β€” cosine function (x in radians)
  • sin(x) β€” sinus function
  • tan(x) β€” tangent function
  • acos(x) β€” arc cosine function
  • asin(x) β€” arc sinus function
  • atan(x) β€” arc tangent function
  • atan2(y, x) β€” arc tangent function of two variables (y, x).
  • cosh(x) β€” hyperbolic cosine function
  • sinh(x) β€” hyperbolic sinus function
  • tanh(x) β€” hyperbolic tangent function
  • sqrt(x) β€” square root function
  • pow(x,y) β€” x raised to the power of y
  • exp(x) β€” e to the power of x
  • log(x) β€” natural logarithm of x
  • log10() β€” base-10 logarithm of x
  • ceil(x) β€” rounds x upwards to the nearest integer
  • floor(x) β€” rounds x downwards to the nearest integer
  • fabs(x) β€” absolute value
  • fmod(x, y) β€” remainder of dividing x by y
  • rand(x) β€” pseudo-random value between 0 and 1

🧚 Vector functions 🧚

  • cross(x, y) β€” cross product of x and y
  • dot(x,y) β€” dot product of x and y (returns scalar value)
  • length(x) β€” length of x (returns scalar value)
  • normalize(x) β€” returns normalized version of x
  • x[y] β€” access components in x (y should be a scalar value in the range [0,2])

There are also some named constants that can be used:

  • MAXFLOAT
  • MINFLOAT
  • M_E
  • M_LOG2E
  • M_LOG10E
  • M_LN2
  • M_PI
  • M_SQRT2 β€” sqrt(2)
  • M_SQRT1_2 β€” sqrt(1/2)

The only control flow available is the ? operator. An example:

oa = (a > b) ? (a * 0.5) : (b * c)

(The parentheses are not necessary, they're there just to make the example easier to read. Considerate of them honestly 🫢)

In addition to the standard comparison operators (<, >, <=, >=, ==, !=), you can also use && (AND) and || (OR) to combine expression, and the unary ! (NOT) operator.

One final thing worth mentioning are the temporary variables. There exist sixteen temporary variables that can be used in expressions. ta, tb, tc, td, te, tf, tg, and th are scalar variables, and tA, tB, tC, tD, tE, tF, tG, and tH are vector variables. They're usually used when you have more than one expression that should be evaluated in order. ✨

An example with three expressions:

ta = a * b; tb = c + d; tc = e - f
tA = vec3f(ta, tb, tc) + A
oA = tA * B

That example just shows how temporary variables can be used to make your expressions easier to read. And please note β€” it's possible to have several statements in one expression. You just separate them with semicolons. Periodt. πŸ’…

Here's a simple example of how an SoCalculator engine may be used in an .iv file:

DEF mycamera PerspectiveCamera {
  orientation 1 0 0 1.57
}

DEF headlight DirectionalLight {
  intensity 0.8
  direction 0 0 1
}

Separator {
  # Render a cube not affected by lighting
  LightModel { model BASE_COLOR }
  BaseColor { rgb = Calculator {
                      a = USE headlight . intensity
                      expression [ "oA = vec3f( a, a, a)" ]
                    } . oA }
  Cube {}
}

In the example, the color of the Cube is a function of the intensity of the DirectionalLight, even though the Cube is rendered without lighting because of the BASE_COLOR LightModel. It's giving sneaky little dependency, and we're obsessed. 😌


πŸŽ€ Constructor & Destructor Documentation πŸŽ€

SoCalculator::SoCalculator (void )

Constructor. ✨

SoCalculator::~SoCalculator (void ) [protected], [virtual]

Destructor. πŸ’€


πŸ‘‘ Member Function Documentation πŸ‘‘

SoType SoCalculator::getClassTypeId (void ) [static]

This static method returns the SoType object associated with objects of this class.

SoType SoCalculator::getTypeId (void ) const [virtual]

Returns the type identification of an object derived from a class inheriting SoBase. This is used for runtime type checking and "downward" casting.

Implements SoBase.

const SoFieldData ** SoCalculator::getInputDataPtr (void ) [static], [protected]

Returns the SoFieldData class which holds information about inputs in this engine.

const SoEngineOutputData ** SoCalculator::getOutputDataPtr (void ) [static], [protected]

Returns the SoEngineOutputData class which holds information about the outputs in this engine.

const SoFieldData * SoCalculator::getFieldData (void ) const [virtual]

Returns the SoFieldData class which holds information about inputs in this engine.

Reimplemented from SoFieldContainer.

const SoEngineOutputData * SoCalculator::getOutputData (void ) const [virtual]

Returns the SoEngineOutputData class which holds information about the outputs in this engine.

Implements SoEngine.

void * SoCalculator::createInstance (void ) [static]

Creates a new instance of the class type corresponding to the SoType object.

void SoCalculator::inputChanged (SoField * which) [protected], [virtual]

Called when an input is changed. The default method does nothing, but subclasses may override this method to do The Right Thing when a specific field is changed. 🫑

Reimplemented from SoEngine.


πŸ’– Member Data Documentation πŸ’–

SoMFFloat SoCalculator::a

Input floating point value for the expressions.

SoMFFloat SoCalculator::b

Input floating point value for the expressions.

SoMFFloat SoCalculator::c

Input floating point value for the expressions.

SoMFFloat SoCalculator::d

Input floating point value for the expressions.

SoMFFloat SoCalculator::e

Input floating point value for the expressions.

SoMFFloat SoCalculator::f

Input floating point value for the expressions.

SoMFFloat SoCalculator::g

Input floating point value for the expressions.

SoMFFloat SoCalculator::h

Input floating point value for the expressions.

SoMFVec3f SoCalculator::A

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::B

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::C

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::D

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::E

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::F

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::G

Input vector with three floating point values for the expressions.

SoMFVec3f SoCalculator::H

Input vector with three floating point values for the expressions.

SoMFString SoCalculator::expression

Mathematical expressions for the calculator.

SoEngineOutput SoCalculator::oa

(SoMFFloat) Output value with result from the calculations.

SoEngineOutput SoCalculator::ob

(SoMFFloat) Output value with result from the calculations.

SoEngineOutput SoCalculator::oc

(SoMFFloat) Output value with result from the calculations.

SoEngineOutput SoCalculator::od

(SoMFFloat) Output value with result from the calculations.

SoEngineOutput SoCalculator::oA

(SoMFVec3f) Output value with result from the calculations.

SoEngineOutput SoCalculator::oB

(SoMFVec3f) Output value with result from the calculations.

SoEngineOutput SoCalculator::oC

(SoMFVec3f) Output value with result from the calculations.

SoEngineOutput SoCalculator::oD

(SoMFVec3f) Output value with result from the calculations.


🌈 Author 🌈

Generated automatically by Doxygen for Coin from the source code. Yes bestie, a robot wrote this about a robot calculator. We love a machine-written king. πŸ‘‘


And that's the whole page, babes! πŸŽ€ This was Version 4.0.10, dated Thu Jun 25 2026 00:00:00, filed under SoCalculator(3). Go forth and calculate. πŸ’…βœ¨

πŸ“¦ where this page comes from