Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Body.h
1// trax track library
2// AD 2023
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8//
9// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
10// Copyright (c) 2019 Marc-Michael Horstmann
11//
12// Permission is hereby granted to any person obtaining a copy of this software
13// and associated source code (the "Software"), to use, view, and study the
14// Software for personal or internal business purposes, subject to the following
15// conditions:
16//
17// 1. Redistribution, modification, sublicensing, or commercial use of the
18// Software is NOT permitted without prior written consent from the copyright
19// holder.
20//
21// 2. The Software is provided "AS IS", without warranty of any kind, express
22// or implied.
23//
24// 3. All copies of the Software must retain this license notice.
25//
26// For further information, please contact: horstmann.marc@trendverlag.de
27
28#pragma once
29
30#include "trax/Configuration.h"
31#include "trax/Units.h"
32
33#include "spat/Frame.h"
34#include "spat/Matrix.h"
35#include "spat/Box.h"
36#include "spat/Sphere.h"
37
38namespace trax{
39
44 struct Body{
45
46 // Body's name:
47
52 virtual void SetName( const char* name ) noexcept = 0;
53
54
56 virtual const char* GetName() const noexcept = 0;
57
58
59 // Body's pose:
60
66 virtual void SetFrame( const spat::Frame<Length,One>& frame ) noexcept = 0;
67
68
70 virtual void GetFrame( spat::Frame<Length,One>& frame ) const noexcept = 0;
71
72
75 virtual void WakeUp() = 0;
76
77
79 virtual bool IsSleeping() const noexcept = 0;
80
81
82 virtual void SetSleepDelay( Time threshold ) = 0;
83
84 virtual Time GetSleepDelay() const noexcept = 0;
85
86 virtual void SetSleepThreshold( decltype(Velocity{}*Velocity{}) threshold ) = 0;
87
88 virtual decltype(Velocity{}*Velocity{}) GetSleepThreshold() const noexcept = 0;
89
90
91 //Mass and inertia:
92
99 virtual void SetMass( Mass mass ) = 0;
100
101
103 virtual Mass GetMass() const noexcept = 0;
104
105
107 virtual void CenterOfMass( const spat::Position<Length>& pos ) noexcept = 0;
108
109
111 virtual spat::Position<Length> CenterOfMass() const noexcept = 0;
112
113
126 virtual void InertiaTensor( const spat::SquareMatrix<Area,3>& specificInertiaTensor ) = 0;
127
128
130 virtual spat::SquareMatrix<Area,3> InertiaTensor() const = 0;
131
132
133
134
135
136
137
144 virtual void SetLinearVelocity( const spat::Vector<Velocity>& v ) = 0;
145
146
148 virtual void GetLinearVelocity( spat::Vector<Velocity>& v ) const = 0;
149
150
157 virtual void SetAngularVelocity( const spat::Vector<AngularVelocity>& w ) = 0;
158
159
161 virtual void GetAngularVelocity( spat::Vector<AngularVelocity>& w ) const = 0;
162
163
164
165 // virtual Shape& GetGeomList() noexcept = 0;
166 //...
167
168 virtual ~Body() = default;
169 };
170
171
178
180
183}
184
Square matrix with nColumns == nRows.
Definition Matrix.h:278
Value< Dimension< 2, 0, 0 > > Area
Area.
Definition DimensionedValues.h:325
Value< Dimension< 0, 0, -1 > > AngularVelocity
Angular velocity.
Definition DimensionedValues.h:323
Value< Dimension< 1, 0, -1 > > Velocity
Velocity.
Definition DimensionedValues.h:331
Value< Dimension< 0, 0, 0 > > One
Dimensionless value.
Definition DimensionedValues.h:319
Value< Dimension< 1, 0, 0 > > Length
Length.
Definition DimensionedValues.h:324
Value< Dimension< 0, 1, 0 > > Mass
Mass.
Definition DimensionedValues.h:327
Value< Dimension< 0, 0, 1 > > Time
Time.
Definition DimensionedValues.h:329
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
dclspc spat::SquareMatrix< Area, 3 > SpecificInertiaTensorFor(const spat::Box< Length > &box)
Calculates the specific inertia tensor for a special shape.
dclspc spat::SquareMatrix< Area, 3 > SpecificInertiaTensorForCylinder(Length radius, Length length)
Calculates the specific inertia tensor for a special shape.
Axis aligned box.
Definition Box.h:41
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
Implements a 3D - position in cartesian coordinates.
Definition Position.h:46
Sphere with center and radius.
Definition Sphere.h:39
Implements a 3D - vector in cartesian coordinates.
Definition Vector.h:48
A dynamic object in physical space.
Definition Body.h:44
virtual void SetMass(Mass mass)=0
Sets the mass of the Body.
virtual void SetLinearVelocity(const spat::Vector< Velocity > &v)=0
Sets the velocity of the barycenter of this Body.
virtual void SetName(const char *name) noexcept=0
Sets the name of the Body.
virtual bool IsSleeping() const noexcept=0
Is the body deactivated?
virtual void CenterOfMass(const spat::Position< Length > &pos) noexcept=0
Sets the center of mass in Body space.
virtual Mass GetMass() const noexcept=0
virtual void SetAngularVelocity(const spat::Vector< AngularVelocity > &w)=0
Sets the rotational velocity around the barycenter of this Body.
virtual void GetLinearVelocity(spat::Vector< Velocity > &v) const =0
Gets the velocity of the barycenter of this Body.
virtual void InertiaTensor(const spat::SquareMatrix< Area, 3 > &specificInertiaTensor)=0
Sets the specific inertia tensor of the Body.
virtual void GetAngularVelocity(spat::Vector< AngularVelocity > &w) const =0
Sets the rotational velocity around the barycenter of this Body.
virtual void SetFrame(const spat::Frame< Length, One > &frame) noexcept=0
Sets position and orientation (pose) in global coordinates.
virtual void WakeUp()=0
Wakes the Body if it was deactivated due to not being in move.
virtual void GetFrame(spat::Frame< Length, One > &frame) const noexcept=0
Gets the pose in global coordinates.
virtual const char * GetName() const noexcept=0