Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
DynMatrix.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2022 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10class [[nodiscard]] DynMatrix
11{
12public:
14 DynMatrix(const DynMatrix &) = default;
15 DynMatrix(uint inRows, uint inCols) : mRows(inRows), mCols(inCols) { mElements.resize(inRows * inCols); }
16
18 float operator () (uint inRow, uint inCol) const { JPH_ASSERT(inRow < mRows && inCol < mCols); return mElements[inRow * mCols + inCol]; }
19 float & operator () (uint inRow, uint inCol) { JPH_ASSERT(inRow < mRows && inCol < mCols); return mElements[inRow * mCols + inCol]; }
20
22 uint GetCols() const { return mCols; }
23 uint GetRows() const { return mRows; }
24
25private:
26 uint mRows;
27 uint mCols;
28 Array<float> mElements;
29};
30
unsigned int uint
Definition: Core.h:426
#define JPH_NAMESPACE_END
Definition: Core.h:354
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:348
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
Dynamic resizable matrix class.
Definition: DynMatrix.h:11
DynMatrix(const DynMatrix &)=default
Constructor.
uint GetCols() const
Get dimensions.
Definition: DynMatrix.h:22
uint GetRows() const
Definition: DynMatrix.h:23
DynMatrix(uint inRows, uint inCols)
Definition: DynMatrix.h:15