Class Node#
Defined in File Node.h
Inheritance Relationships#
Base Type#
public Karana::Frame::Frame(Class Frame)
Derived Types#
public Karana::Dynamics::ConstraintNode(Class ConstraintNode)public Karana::Dynamics::HingeNode(Class HingeNode)
Class Documentation#
-
class Node : public Karana::Frame::Frame#
Represents the body node base class.
This class is for nodes attached to PhysicalBody instances. See
Body nodes section for more information on the Node class.
Subclassed by Karana::Dynamics::ConstraintNode, Karana::Dynamics::HingeNode
Public Functions
-
virtual void detach()#
Method to detach the node from the current parent body.
Once detached, the node is put in the pool of detached nodes for possible reuse when new nodes are needed.
-
Node(std::string_view name, const kc::ks_ptr<PhysicalBody> &bd)#
Node constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.
- Parameters:
name – Name of the node.
bd – PhysicalBody to attach the node to.
-
inline const kc::ks_ptr<PhysicalBody> &parentBody() const#
Returns the type string of the SubTree.
Return the PhysicalBody parent body for the node.
- Returns:
The type string.
- Returns:
the parent PhysicalBody instance
-
virtual bool isReady() const override#
Checks is the params for the object have been initialized.
- Returns:
True if the params have set up.
-
void setBodyToNodeTransform(const km::HomTran &t)#
Set the node’s transform with respect to the parent PhysicalBody’s body frame.
This transform defines the Node’s location for an undeformed PhysicalBody parent body. Use Karana::Frame::FrameToFrame queries to find the actual location of a Node after body deformation.
- Parameters:
t – the offset transform
-
km::HomTran getBodyToNodeTransform() const#
Return the node’s transform with respect to the parent PhysicalBody’s body frame.
This transform defines the Node’s location for an undeformed PhysicalBody parent body. Use Karana::Frame::FrameToFrame queries to find the actual location of a Node after body deformation.
- Returns:
the node’s offset transform
-
bool isExternalForceNode() const#
Check whether the Node is a force node.
A force node is one that has been designated as one that can apply forces on the body. See Body nodes section for more on force nodes.
- Returns:
true if the node is a force node
-
km::SpatialVector nodeObservedSpatialAccel() const#
Return the node frame observed spatial acceleration of the node with respect to the Newtonian frame.
This is the spatial acceleration of the node with respect to the Newtonian Karana::Frame::Frame, as observed from and represented in the node frame. Note that this is not and should not be confused with newtoninan_frame.frameToFrame(node).relSpAccel() which returns the Newtonian frame observed acceleration of the node with respect to the Newtonian frame!
- Returns:
the spatial acceleration vector
-
inline const km::SpatialVector &getSpForce() const#
Get the external spatial force at the node represented in the node frame.
- Returns:
the spatial force vector
-
virtual void setExternalSpForce(const km::SpatialVector &spforce, const kc::ks_ptr<kf::Frame> &ref_frame = nullptr)#
Set the external spatial force at the node represented in the specified Karana::Frame::Frame frame.
This method resets the specified spatial force to the currently set spatial force in the node. If no frame is specified, then the spatial force is assumed to be represented in the local node frame, else the force is immediately rotated from the specified frame into the node’s local frame. Note that most algorithms will check this node for a spatial force only it has been registered as a force node - so make sure that the node has bee registered as a force node.
- Parameters:
spforce – The spatial force value
ref_frame – The reference Karana::Frame::Frame frame for the spatial force values
-
virtual void accumExternalSpForce(const km::SpatialVector &spforce, const kc::ks_ptr<kf::Frame> &ref_frame = nullptr)#
Accumulate the specified external spatial force at the node represented in the specified Karana::Frame::Frame frame.
Accumulate the external spatial force at the node represented in the specified frame. This method adds the specified spatial force to the currently set spatial force in the node. If no frame is specified, then the spatial force is assumed to be represented in the local node frame. Note that most algorithms will check this node for a spatial force only it has been registered as a force node - so make sure that this has been done.
- Parameters:
spforce – The spatial force value
ref_frame – The reference frame for the spatial force values
-
inline const kc::ks_ptr<NodeDeformationProvider> &deformationProvider() const#
Return the <NodeDeformationProvider deformation provider for the node.
- Returns:
the NodeDeformationProvider instance
-
virtual std::string dumpString(std::string_view prefix, const Karana::Core::Base::DumpOptions *options) const override#
Return a formatted string containing information about this object.
- Parameters:
prefix – String prefix to use for formatting.
options – Dump options (if null, defaults will be used).
- Returns:
A string representation of the object.
-
kc::ks_ptr<kf::OrientedChainedFrameToFrame> newtonianToNodeFrameToFrame() const#
Return the Karana::Frame::FrameToFrame from the Newtonian frame to the body frame.
- Returns:
the Karana::Frame::FrameToFrame instance
Public Static Functions
-
static kc::ks_ptr<Node> lookupOrCreate(std::string_view name, kc::ks_ptr<PhysicalBody> bd, bool force_node = false)#
Factory method to create a Node instance.
This method first checks if a detached node is available for use. If not, the method creates a new Node for the body.
- Parameters:
bd – the physical parent body
name – the name for the node
force_node – if true, the node is marked as one that can apply forces
- Returns:
a Node instance
-
static kc::ks_ptr<Node> lookupOrCreateContact(const kc::ks_ptr<PhysicalBody> &bd, const km::HomTran &T, std::string_view name = "")#
Factory method to create a Node instance that is used for contact forces.
A contact force node is one whose forces will only apply for for one dynamics calculation. Whenever the externals are cleared, these nodes will become inactive. These nodes are always force nodes. If no name is provided, one will be given to them automatically.
This method first checks if a detached node is available for use. If not, the method creates a new Node for the body.
- Parameters:
bd – The physical parent body
T – The transform of the node relative to the body.
name – instance name
- Returns:
a Node instance
Protected Functions
-
void _clearExternals()#
Zero out the external spatial force at the node.
-
void _discard(kc::ks_ptr<kc::Base> &base) override#
Discard a node.
- Parameters:
base – - A base pointer to the node to discard.
-
void _createStickParts(kc::ks_ptr<ks::ProxyScene> &scene, const StickPartsConfig &c, bool add_sphere)#
Create stick parts for the node.
- Parameters:
scene – the proxy scene
c – the stick parts configuration data
add_sphere – if true, add a sphere scene part for the node
Protected Attributes
-
kc::ks_ptr<PhysicalBody> _parent_body = nullptr#
the parent body the node is attached to
-
km::SpatialVector _node_frame_spforce#
external force being applied in the node frame
-
kc::ks_ptr<kc::DataCache<km::SpatialVector>> _external_force_cache = nullptr#
data cache for handling external forces
-
kc::ks_ptr<kf::OrientedChainedFrameToFrame> _newtonian2node_f2f = nullptr#
f2f from the Newtonian frame to this node
-
kc::ks_ptr<kf::OrientedChainedFrameToFrame> _pnode2node_f2f = nullptr#
f2f from the parent body’s pnode to this node
-
kc::ks_ptr<NodeDeformationProvider> _deformation_provider = nullptr#
helper class that carries data and methods for the specific type of node deformation
-
virtual void detach()#