wfmath 1.0.3
A math library for the Worldforge system.
ball.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-27
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 "ball_funcs.h"
31#include "miniball_funcs.h"
32#include "vector.h"
33
34#include <vector>
35#include <cmath>
36
37namespace WFMath {
38
39template<> Ball<3>& Ball<3>::rotateCorner(const Quaternion&, size_t)
40{
41 return *this;
42}
43
44template<> Ball<3>& Ball<3>::rotateCenter(const Quaternion&)
45{
46 return *this;
47}
48
49template<> Ball<3>& Ball<3>::rotatePoint(const Quaternion& q, const Point<3>& p)
50{
51 m_center.rotate(q, p); return *this;
52}
53
54template<> Ball<3> Ball<3>::toParentCoords(const Point<3>& origin,
55 const Quaternion& rotation) const
56{
57 return Ball<3>(m_center.toParentCoords(origin, rotation), m_radius);
58}
59
60template<> Ball<3> Ball<3>::toLocalCoords(const Point<3>& origin,
61 const Quaternion& rotation) const
62{
63 return Ball<3>(m_center.toLocalCoords(origin, rotation), m_radius);
64}
65
66template Ball<2> BoundingSphere<2, std::vector>(std::vector<Point<2>,
67 std::allocator<Point<2> > > const&);
68
69template Ball<2> BoundingSphereSloppy<2, std::vector>(std::vector<Point<2>,
70 std::allocator<Point<2> > > const&);
71
72template Ball<3> BoundingSphere<3, std::vector>(std::vector<Point<3>,
73 std::allocator<Point<3> > > const&);
74
75template Ball<3> BoundingSphereSloppy<3, std::vector>(std::vector<Point<3>,
76 std::allocator<Point<3> > > const&);
77
78template Ball<2> Point<2>::boundingSphere() const;
79template Ball<2> Point<2>::boundingSphereSloppy() const;
80
81template Ball<3> Point<3>::boundingSphere() const;
82template Ball<3> Point<3>::boundingSphereSloppy() const;
83
84template class Ball<2>;
85template class Ball<3>;
86
87static_assert(std::is_standard_layout<Ball<3>>::value, "Ball should be standard layout.");
88static_assert(std::is_trivially_copyable<Ball<3>>::value, "Ball should be trivially copyable.");
89
90static_assert(std::is_standard_layout<Ball<2>>::value, "Ball should be standard layout.");
91static_assert(std::is_trivially_copyable<Ball<2>>::value, "Ball should be trivially copyable.");
92}
Generic library namespace.
Definition: shape.h:41