krita
kis_vec.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kis_vec.h"
00022
00023 KisVector2D& KisVector2D::normalize()
00024 {
00025 double length, ilength;
00026
00027 length = m_x*m_x + m_y*m_y;
00028 length = sqrt (length);
00029
00030 if (length > epsilon)
00031 {
00032 ilength = 1/length;
00033 m_x *= ilength;
00034 m_y *= ilength;
00035 }
00036 return *this;
00037 }
00038
00039 KisVector3D& KisVector3D::normalize()
00040 {
00041 double length, ilength;
00042
00043 length = m_x*m_x + m_y*m_y + m_z*m_z;
00044 length = sqrt (length);
00045
00046 if (length > epsilon)
00047 {
00048 ilength = 1/length;
00049 m_x *= ilength;
00050 m_y *= ilength;
00051 m_z *= ilength;
00052 }
00053 return *this;
00054 }
00055
00056 KisVector3D& KisVector3D::crossProduct(const KisVector3D &v)
00057 {
00058 double x,y,z;
00059
00060 x = m_y*v.m_z - m_z*v.m_y;
00061 y = m_z*v.m_x - m_x*v.m_z;
00062 z = m_x*v.m_y - m_y*v.m_x;
00063 m_x=x; m_y=y; m_z=z;
00064
00065 return *this;
00066 }
00067
|