Newton Dynamics  4.00
ndSpatialMatrix.h
1 /* Copyright (c) <2003-2022> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __ND_SPATIAL_MATRIX_H__
23 #define __ND_SPATIAL_MATRIX_H__
24 
25 #include "ndCoreStdafx.h"
26 #include "ndTypes.h"
27 #include "ndVector.h"
28 #include "ndSpatialVector.h"
29 
31 {
32  public:
33  D_OPERATOR_NEW_AND_DELETE
34 
35  inline ndSpatialMatrix()
36  {
37  }
38 
39  inline ndSpatialMatrix(ndFloat32 val)
40  {
41  const ndSpatialVector row (val);
42  for (ndInt32 i = 0; i < 6; ++i)
43  {
44  m_rows[i] = row;
45  }
46  }
47 
48  inline ~ndSpatialMatrix()
49  {
50  }
51 
52  inline ndSpatialVector& operator[] (ndInt32 i)
53  {
54  ndAssert(i < 6);
55  ndAssert(i >= 0);
56  return m_rows[i];
57  }
58 
59  inline const ndSpatialVector& operator[] (ndInt32 i) const
60  {
61  ndAssert(i < 6);
62  ndAssert(i >= 0);
63  return m_rows[i];
64  }
65 
66  D_CORE_API ndSpatialMatrix Inverse(ndInt32 rows) const;
67 
68  inline ndSpatialVector VectorTimeMatrix(const ndSpatialVector& jacobian) const
69  {
70  ndSpatialVector tmp(m_rows[0].Scale (jacobian[0]));
71  for (ndInt32 i = 1; i < 6; ++i)
72  {
73  tmp = tmp + m_rows[i].Scale(jacobian[i]);
74  }
75  return tmp;
76  }
77 
78  inline ndSpatialVector VectorTimeMatrix(const ndSpatialVector& jacobian, ndInt32 dof) const
79  {
80  ndSpatialVector tmp(ndFloat32 (0.0f));
81  for (ndInt32 i = 0; i < dof; ++i)
82  {
83  tmp = tmp + m_rows[i].Scale(jacobian[i]);
84  }
85  return tmp;
86  }
87 
88  ndSpatialVector m_rows[6];
89 };
90 
91 #endif
92 
ndSpatialVector
Definition: ndSpatialVector.h:31
ndSpatialMatrix
Definition: ndSpatialMatrix.h:31