2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FGrpFloatPoint.cpp
20 * @brief This is the implementation file for FloatPoint class.
22 * This file contains implementation of FloatPoint class.
26 #include <FGrpFloatPoint.h>
32 // epsilon is assumed to be 0.00001f, not 1.192092896e-07f
33 const float _EPSILON = 0.00001f;
36 _IsEqual(float f1, float f2)
38 return (((f1 > f2) ? f1 - f2 : f2 - f1) < _EPSILON);
43 namespace Tizen { namespace Graphics
46 FloatPoint::FloatPoint(void)
53 FloatPoint::FloatPoint(const FloatPoint& rhs)
60 FloatPoint::FloatPoint(float x_, float y_)
67 FloatPoint::~FloatPoint(void)
72 FloatPoint::operator=(const FloatPoint& rhs)
87 FloatPoint::operator ==(const FloatPoint& rhs) const
89 return ((_IsEqual(this->x, rhs.x) && _IsEqual(this->y, rhs.y)) ? true : false);
93 FloatPoint::operator !=(const FloatPoint& rhs) const
95 return (!operator ==(rhs));
99 FloatPoint::operator +(const FloatPoint& rhs) const
103 point.x = this->x + rhs.x;
104 point.y = this->y + rhs.y;
110 FloatPoint::operator -(const FloatPoint& rhs) const
114 point.x = this->x - rhs.x;
115 point.y = this->y - rhs.y;
121 FloatPoint::operator +=(const FloatPoint& point)
130 FloatPoint::operator -=(const FloatPoint& point)
139 FloatPoint::Equals(const Object& rhs) const
141 const FloatPoint* pPoint = dynamic_cast <const FloatPoint*>(&rhs);
148 return (*this == *pPoint);
152 FloatPoint::GetHashCode(void) const
154 const float inverseEpsilon = 1.0f / _EPSILON;
156 int reinterpretedX = int(this->x * inverseEpsilon);
157 int reinterpretedY = int(this->y * inverseEpsilon);
159 return reinterpretedX ^ (reinterpretedY * 31);
163 FloatPoint::SetPosition(float x, float y)
170 FloatPoint::SetPosition(const FloatPoint& point)
177 FloatPoint::Translate(float x, float y)
183 }} // Tizen::Graphics