wfmath 1.0.3
A math library for the Worldforge system.
segment.cpp
1// vector.cpp (Vector<> implementation)
2//
3// The WorldForge Project
4// Copyright (C) 2011 The WorldForge Project
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19//
20// For information about WorldForge and its authors, please contact
21// the Worldforge Web Site at http://www.worldforge.org.
22
23// Author: Alistair Riddoch
24// Created: 2011-1-29
25
26// Extensive amounts of this material come from the Vector2D
27// and Vector3D classes from stage/math, written by Bryce W.
28// Harrington, Kosh, and Jari Sundell (Rakshasa).
29
30#include "segment_funcs.h"
31
32#include "axisbox.h"
33#include "ball.h"
34#include "vector.h"
35
36#include <cmath>
37
38namespace WFMath {
39
40template<> Segment<3>& Segment<3>::rotatePoint(const Quaternion& q,
41 const Point<3>& p)
42{
43 m_p1.rotate(q, p);
44 m_p2.rotate(q, p);
45 return *this;
46}
47
48template<> Segment<3>& Segment<3>::rotateCenter(const Quaternion& q)
49{
50 rotatePoint(q, getCenter());
51 return *this;
52}
53
54template<> Segment<3> Segment<3>::toParentCoords(const Point<3>& origin,
55 const Quaternion& rotation) const
56{
57 return Segment(m_p1.toParentCoords(origin, rotation),
58 m_p2.toParentCoords(origin, rotation));
59}
60
61template<> Segment<3> Segment<3>::toLocalCoords(const Point<3>& origin,
62 const Quaternion& rotation) const
63{
64 return Segment(m_p1.toLocalCoords(origin, rotation),
65 m_p2.toLocalCoords(origin, rotation));
66}
67
68
69template class Segment<2>;
70template class Segment<3>;
71
72static_assert(std::is_standard_layout<Segment<2>>::value, "Segment should be standard layout.");
73static_assert(std::is_trivially_copyable<Segment<2>>::value, "Segment should be trivially copyable.");
74
75static_assert(std::is_standard_layout<Segment<3>>::value, "Segment should be standard layout.");
76static_assert(std::is_trivially_copyable<Segment<3>>::value, "Segment should be trivially copyable.");
77
78}
Generic library namespace.
Definition: shape.h:41