Toggle navigation
PlayRho
0.9.0
GitHub
Main Page
Modules
Classes
Files
Examples
File List
File Members
Collision
Shapes
EdgeShapeConf.cpp
Go to the documentation of this file.
1
/*
2
* Original work Copyright (c) 2006-2010 Erin Catto http://www.box2d.org
3
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4
*
5
* This software is provided 'as-is', without any express or implied
6
* warranty. In no event will the authors be held liable for any damages
7
* arising from the use of this software.
8
* Permission is granted to anyone to use this software for any purpose,
9
* including commercial applications, and to alter it and redistribute it
10
* freely, subject to the following restrictions:
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
* 2. Altered source versions must be plainly marked as such, and must not be
16
* misrepresented as being the original software.
17
* 3. This notice may not be removed or altered from any source distribution.
18
*/
19
20
#include <
PlayRho/Collision/Shapes/EdgeShapeConf.hpp
>
21
22
namespace
playrho
{
23
namespace
d2 {
24
25
EdgeShapeConf::EdgeShapeConf
(
Length2
vA,
Length2
vB,
const
EdgeShapeConf
& conf) noexcept:
26
ShapeBuilder
{conf}, vertexRadius{conf.vertexRadius}, m_vertices{vA, vB}
27
{
28
const
auto
normal =
GetUnitVector
(
GetFwdPerpendicular
(vB - vA));
29
m_normals[0] = normal;
30
m_normals[1] = -normal;
31
}
32
33
EdgeShapeConf
&
EdgeShapeConf::Set
(
Length2
vA,
Length2
vB) noexcept
34
{
35
m_vertices[0] = vA;
36
m_vertices[1] = vB;
37
const
auto
normal =
GetUnitVector
(
GetFwdPerpendicular
(vB - vA));
38
m_normals[0] = normal;
39
m_normals[1] = -normal;
40
return
*
this
;
41
}
42
43
EdgeShapeConf
&
EdgeShapeConf::Transform
(
const
Mat22
& m) noexcept
44
{
45
const
auto
newA = m * GetVertexA();
46
const
auto
newB = m * GetVertexB();
47
return
Set
(newA, newB);
48
}
49
50
}
// namespace d2
51
}
// namespace playrho