externals
box2d
unit-test
math_test.cpp
Go to the documentation of this file.
1
// MIT License
2
3
// Copyright (c) 2020 Erin Catto
4
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#include "
box2d/box2d.h
"
24
#include "
doctest.h
"
25
#include <stdio.h>
26
27
DOCTEST_TEST_CASE
(
"math test"
)
28
{
29
SUBCASE
(
"sweep"
)
30
{
31
// From issue #447
32
b2Sweep
sweep;
33
sweep.
localCenter
.
SetZero
();
34
sweep.
c0
.
Set
(-2.0
f
, 4.0
f
);
35
sweep.
c
.
Set
(3.0
f
, 8.0
f
);
36
sweep.
a0
= 0.5f;
37
sweep.
a
= 5.0f;
38
sweep.
alpha0
= 0.0f;
39
40
b2Transform
transform;
41
42
sweep.
GetTransform
(&transform, 0.0
f
);
43
DOCTEST_REQUIRE_EQ
(transform.
p
.
x
, sweep.
c0
.
x
);
44
DOCTEST_REQUIRE_EQ
(transform.
p
.
y
, sweep.
c0
.
y
);
45
DOCTEST_REQUIRE_EQ
(transform.
q
.
c
, cosf(sweep.
a0
));
46
DOCTEST_REQUIRE_EQ
(transform.
q
.
s
, sinf(sweep.
a0
));
47
48
sweep.
GetTransform
(&transform, 1.0
f
);
49
DOCTEST_REQUIRE_EQ
(transform.
p
.
x
, sweep.
c
.
x
);
50
DOCTEST_REQUIRE_EQ
(transform.
p
.
y
, sweep.
c
.
y
);
51
DOCTEST_REQUIRE_EQ
(transform.
q
.
c
, cosf(sweep.
a
));
52
DOCTEST_REQUIRE_EQ
(transform.
q
.
s
, sinf(sweep.
a
));
53
}
54
}
b2Vec2::y
float y
Definition:
b2_math.h:128
DOCTEST_REQUIRE_EQ
#define DOCTEST_REQUIRE_EQ(...)
Definition:
doctest.h:2127
DOCTEST_TEST_CASE
DOCTEST_TEST_CASE("math test")
Definition:
math_test.cpp:27
b2Transform::p
b2Vec2 p
Definition:
b2_math.h:360
b2Sweep::localCenter
b2Vec2 localCenter
local center of mass position
Definition:
b2_math.h:382
b2Sweep::c0
b2Vec2 c0
Definition:
b2_math.h:383
b2Sweep::GetTransform
void GetTransform(b2Transform *transform, float beta) const
Definition:
b2_math.h:687
b2Vec2::SetZero
void SetZero()
Set this vector to all zeros.
Definition:
b2_math.h:50
b2Vec2::Set
void Set(float x_, float y_)
Set this vector to some specified coordinates.
Definition:
b2_math.h:53
b2Sweep::alpha0
float alpha0
Definition:
b2_math.h:388
SUBCASE
#define SUBCASE
Definition:
doctest.h:2447
f
f
b2Rot::s
float s
Sine and cosine.
Definition:
b2_math.h:333
b2Transform
Definition:
b2_math.h:338
b2Rot::c
float c
Definition:
b2_math.h:333
b2Sweep
Definition:
b2_math.h:368
b2Vec2::x
float x
Definition:
b2_math.h:128
b2Transform::q
b2Rot q
Definition:
b2_math.h:361
box2d.h
doctest.h
b2Sweep::a
float a
world angles
Definition:
b2_math.h:384
b2Sweep::a0
float a0
Definition:
b2_math.h:384
b2Sweep::c
b2Vec2 c
center world positions
Definition:
b2_math.h:383
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:08