23 #include <QTextStream>
52 return *
this * ( 1.0 / scalar );
83 double ang = atan2(
m_y,
m_x );
84 return ang < 0.0 ? ang + 2.0 *
M_PI : ang;
94 double ang = atan2(
m_y,
m_x ) + rot;
96 return QgsVector( len * cos( ang ), len * sin( ang ) );
105 throw QgsException(
"normal vector of null vector undefined" );
125 QTextStream ot( &rep );
126 ot.setRealNumberPrecision( 12 );
133 QString rep = QString::number(
m_x,
'f', thePrecision ) + QString(
"," ) +
134 QString::number(
m_y,
'f', thePrecision );
140 int myDegreesX = int( qAbs(
m_x ) );
141 float myFloatMinutesX = float(( qAbs(
m_x ) - myDegreesX ) * 60 );
142 int myIntMinutesX = int( myFloatMinutesX );
143 float mySecondsX = float( myFloatMinutesX - myIntMinutesX ) * 60;
145 int myDegreesY = int( qAbs(
m_y ) );
146 float myFloatMinutesY = float(( qAbs(
m_y ) - myDegreesY ) * 60 );
147 int myIntMinutesY = int( myFloatMinutesY );
148 float mySecondsY = float( myFloatMinutesY - myIntMinutesY ) * 60;
150 QString myXHemisphere =
m_x < 0 ? QObject::tr(
"W" ) : QObject::tr(
"E" );
151 QString myYHemisphere =
m_y < 0 ? QObject::tr(
"S" ) : QObject::tr(
"N" );
152 QString rep = QString::number( myDegreesX ) + QChar( 176 ) +
153 QString::number( myIntMinutesX ) + QString(
"'" ) +
154 QString::number( mySecondsX,
'f', thePrecision ) + QString(
"\"" ) +
155 myXHemisphere + QString(
"," ) +
156 QString::number( myDegreesY ) + QChar( 176 ) +
157 QString::number( myIntMinutesY ) + QString(
"'" ) +
158 QString::number( mySecondsY,
'f', thePrecision ) + QString(
"\"" ) +
166 return QString(
"POINT(%1 %2)" ).arg( QString::number(
m_x,
'f', 18 ) ).arg( QString::number(
m_y,
'f', 18 ) );
181 double dx = other.
x() -
m_x;
182 double dy = other.
y() -
m_y;
183 return ( atan2( dx, dy ) * 180.0 /
M_PI );
189 if ((
m_x == other.
x() ) && (
m_y == other.
y() ) )
197 if ((
m_x == other.
x() ) && (
m_y == other.
y() ) )
205 if ( &other !=
this )
224 qAbs(( b.
y() - a.
y() ) *(
m_x - a.
x() ) - (
m_y - a.
y() ) *( b.
x() - a.
x() ) )
225 >= qMax( qAbs( b.
x() - a.
x() ), qAbs( b.
y() - a.
y() ) )
230 if (( b.
x() < a.
x() && a.
x() <
m_x ) || ( b.
y() < a.
y() && a.
y() <
m_y ) )
234 if ((
m_x < a.
x() && a.
x() < b.
x() ) || (
m_y < a.
y() && a.
y() < b.
y() ) )
238 if (( a.
x() < b.
x() && b.
x() <
m_x ) || ( a.
y() < b.
y() && b.
y() <
m_y ) )
242 if ((
m_x < b.
x() && b.
x() < a.
x() ) || (
m_y < b.
y() && b.
y() < a.
y() ) )
258 t = (
m_x * ny -
m_y * nx - x1 * ny + y1 * nx ) / (( x2 - x1 ) * ny - ( y2 - y1 ) * nx );
262 minDistPoint.
setX( x1 );
263 minDistPoint.
setY( y1 );
267 minDistPoint.
setX( x2 );
268 minDistPoint.
setY( y2 );
272 minDistPoint.
setX( x1 + t *( x2 - x1 ) );
273 minDistPoint.
setY( y1 + t *( y2 - y1 ) );
276 double dist =
sqrDist( minDistPoint );