zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Coordinate.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <zeni.h>
19 
20 namespace Zeni {
21 
22  Point2i Point2i::interpolate_to(const float &rhs_part, const Point2i &rhs) const {
23  const float lhs_part = 1.0f - rhs_part;
24  return Point2i(int(lhs_part * x + rhs_part * rhs.x),
25  int(lhs_part * y + rhs_part * rhs.y));
26  }
27 
28  Point2f Point2f::interpolate_to(const float &rhs_part, const Point2f &rhs) const {
29  const float lhs_part = 1.0f - rhs_part;
30  return Point2f(lhs_part * x + rhs_part * rhs.x,
31  lhs_part * y + rhs_part * rhs.y);
32  }
33 
34  Point3i Point3i::interpolate_to(const float &rhs_part, const Point3i &rhs) const {
35  const float lhs_part = 1.0f - rhs_part;
36  return Point3i(int(lhs_part * x + rhs_part * rhs.x),
37  int(lhs_part * y + rhs_part * rhs.y),
38  int(lhs_part * z + rhs_part * rhs.z));
39  }
40 
41  Point3f Point3f::interpolate_to(const float &rhs_part, const Point3f &rhs) const {
42  const float lhs_part = 1.0f - rhs_part;
43  return Point3f(lhs_part * x + rhs_part * rhs.x,
44  lhs_part * y + rhs_part * rhs.y,
45  lhs_part * z + rhs_part * rhs.z);
46  }
47 
48  const int Point2i::z = 0;
49  const float Point2f::z = 0;
50 
51  std::ostream & serialize(std::ostream &os, const Point2i &value) {
52  return serialize(serialize(os, value.x), value.y);
53  }
54 
55  std::ostream & serialize(std::ostream &os, const Point2f &value) {
56  return serialize(serialize(os, value.x), value.y);
57  }
58 
59  std::ostream & serialize(std::ostream &os, const Point3i &value) {
60  return serialize(serialize(serialize(os, value.x), value.y), value.z);
61  }
62 
63  std::ostream & serialize(std::ostream &os, const Point3f &value) {
64  return serialize(serialize(serialize(os, value.x), value.y), value.z);
65  }
66 
67  std::istream & unserialize(std::istream &is, Point2i &value) {
68  return unserialize(unserialize(is, value.x), value.y);
69  }
70 
71  std::istream & unserialize(std::istream &is, Point2f &value) {
72  return unserialize(unserialize(is, value.x), value.y);
73  }
74 
75  std::istream & unserialize(std::istream &is, Point3i &value) {
76  return unserialize(unserialize(unserialize(is, value.x), value.y), value.z);
77  }
78 
79  std::istream & unserialize(std::istream &is, Point3f &value) {
80  return unserialize(unserialize(unserialize(is, value.x), value.y), value.z);
81  }
82 
83 }
Point2i interpolate_to(const float &rhs_part, const Point2i &rhs) const
Get a point inbetween this point and another point of the same type.
Definition: Coordinate.cpp:22
EGLSurface EGLint x
Definition: eglext.h:293
Point3i interpolate_to(const float &rhs_part, const Point3i &rhs) const
Get a point inbetween this point and another point of the same type.
Definition: Coordinate.cpp:34
static const Sint32 z
Definition: Coordinate.h:95
std::istream & unserialize(std::istream &is, Color &value)
Definition: Color.cpp:72
std::ostream & serialize(std::ostream &os, const Color &value)
Definition: Color.cpp:68
A 3D Point represented with floats.
Definition: Coordinate.h:133
A 3D Point represented with integers.
Definition: Coordinate.h:121
static const float z
Definition: Coordinate.h:118
EGLSurface EGLint EGLint y
Definition: eglext.h:293
EGLSurface EGLint void ** value
Definition: eglext.h:301
GLint GLint GLint GLint z
Definition: gl2ext.h:1214
Point2f interpolate_to(const float &rhs_part, const Point2f &rhs) const
Get a point inbetween this point and another point of the same type.
Definition: Coordinate.cpp:28
Point3f interpolate_to(const float &rhs_part, const Point3f &rhs) const
Definition: Coordinate.cpp:41
A 2D Point represented with floats.
Definition: Coordinate.h:98
A 2D Point represented with integers.
Definition: Coordinate.h:85