Revert " modify license, permission and remove ^M char"
[framework/osp/uifw.git] / src / graphics / FGrpFloatPoint3.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FGrpFloatPoint3.cpp
20  * @brief       This is the implementation for %FloatPoint3 class.
21  */
22
23 #include <FGrpFloatPoint3.h>
24 #include <FGrpFloatVector4.h>
25 #include <FBaseFloat.h>
26 #include <FBaseSysLog.h>
27
28 namespace Tizen { namespace Graphics
29 {
30 FloatPoint3::FloatPoint3(void)
31         : __pImpl(null)
32 {
33         x = 0.0f;
34         y = 0.0f;
35         z = 0.0f;
36 }
37
38 FloatPoint3::FloatPoint3(const FloatPoint3& rhs)
39         : __pImpl(null)
40 {
41         x = rhs.x;
42         y = rhs.y;
43         z = rhs.z;
44 }
45
46 FloatPoint3::FloatPoint3(const FloatVector4& vector)
47         : __pImpl(null)
48 {
49         FloatVector4 normalizedVector = vector.GetNormal();
50
51         x = normalizedVector.x;
52         y = normalizedVector.y;
53         z = normalizedVector.z;
54 }
55
56 FloatPoint3::FloatPoint3(const float point[3])
57         : __pImpl(null)
58 {
59         this->x = point[0];
60         this->y = point[1];
61         this->z = point[2];
62 }
63
64 FloatPoint3::FloatPoint3(float x, float y, float z)
65         : __pImpl(null)
66 {
67         this->x = x;
68         this->y = y;
69         this->z = z;
70 }
71
72 FloatPoint3::~FloatPoint3(void)
73 {
74 }
75
76 bool
77 FloatPoint3::operator ==(const FloatPoint3& rhs) const
78 {
79         if (this == &rhs)
80         {
81                 return true;
82         }
83
84         return (x == rhs.x && y == rhs.y && z == rhs.z);
85 }
86
87 FloatPoint3&
88 FloatPoint3::operator =(const FloatPoint3& rhs)
89 {
90         if (this != &rhs)
91         {
92                 x = rhs.x;
93                 y = rhs.y;
94                 z = rhs.z;
95         }
96
97         return *this;
98 }
99
100 FloatPoint3
101 FloatPoint3::operator *(float value) const
102 {
103         return FloatPoint3(x * value, y * value, z * value);
104 }
105
106 FloatPoint3
107 FloatPoint3::operator /(float value) const
108 {
109         return FloatPoint3(x / value, y / value, z / value);
110 }
111
112 FloatPoint3
113 FloatPoint3::operator +(const FloatPoint3& rhs) const
114 {
115         return FloatPoint3(x + rhs.x, y + rhs.y, z + rhs.z);
116 }
117
118 FloatPoint3
119 FloatPoint3::operator -(const FloatPoint3& rhs) const
120 {
121         return FloatPoint3(x - rhs.x, y - rhs.y, z - rhs.z);
122 }
123
124 FloatPoint3&
125 FloatPoint3::operator +=(const FloatPoint3& rhs)
126 {
127         this->x += rhs.x;
128         this->y += rhs.y;
129         this->z += rhs.z;
130
131         return *this;
132 }
133
134 FloatPoint3&
135 FloatPoint3::operator -=(const FloatPoint3& rhs)
136 {
137         this->x -= rhs.x;
138         this->y -= rhs.y;
139         this->z -= rhs.z;
140
141         return *this;
142 }
143
144 bool
145 FloatPoint3::Equals(const Tizen::Base::Object& obj) const
146 {
147         const FloatPoint3* pVector = dynamic_cast <const FloatPoint3*>(&obj);
148
149         if (pVector == null)
150         {
151                 return false;
152         }
153
154         return (*this == *pVector);
155 }
156
157 int
158 FloatPoint3::GetHashCode(void) const
159 {
160         return (Tizen::Base::Float::GetHashCode(x) +
161                         Tizen::Base::Float::GetHashCode(y) +
162                         Tizen::Base::Float::GetHashCode(z));
163 }
164
165 FloatPoint3
166 operator *(const float& value, const FloatPoint3& rhs)
167 {
168         return rhs * value;
169 }
170
171 FloatPoint3
172 operator /(const float& value, const FloatPoint3& rhs)
173 {
174         return rhs / value;
175 }
176
177 }} // Tizen::Graphics