1 /* 2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox (at) kde.org> 3 2004, 2005 Rob Buis <buis (at) kde.org> 4 2005 Eric Seidel <eric (at) webkit.org> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Library General Public 8 License as published by the Free Software Foundation; either 9 version 2 of the License, or (at your option) any later version. 10 11 This library 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 GNU 14 Library General Public License for more details. 15 16 You should have received a copy of the GNU Library General Public License 17 aint with this library; see the file COPYING.LIB. If not, write to 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 */ 21 22 #include "config.h" 23 24 #include <math.h> 25 #include "FloatPoint.h" 26 #include "FloatPoint3D.h" 27 28 namespace WebCore { 29 30 FloatPoint3D::FloatPoint3D() 31 : m_x(0) 32 , m_y(0) 33 , m_z(0) 34 { 35 } 36 37 FloatPoint3D::FloatPoint3D(float x, float y, float z) 38 : m_x(x) 39 , m_y(y) 40 , m_z(z) 41 { 42 } 43 44 FloatPoint3D::FloatPoint3D(const FloatPoint& p) 45 : m_x(p.x()) 46 , m_y(p.y()) 47 , m_z(0) 48 { 49 } 50 51 void FloatPoint3D::normalize() 52 { 53 float length = sqrtf(m_x * m_x + m_y * m_y + m_z * m_z); 54 55 if (length != 0) { 56 m_x /= length; 57 m_y /= length; 58 m_z /= length; 59 } 60 } 61 62 } // namespace WebCore 63 64