22 #include <QTextStream>
51 return *
this * ( 1.0 / scalar );
82 double ang = atan2(
m_y,
m_x );
83 return ang < 0.0 ? ang + 2.0 *
M_PI : ang;
93 double ang = atan2(
m_y,
m_x ) + rot;
95 return QgsVector( len * cos( ang ), len * sin( ang ) );
104 throw QgsException(
"normal vector of null vector undefined" );
124 QTextStream ot( &rep );
125 ot.setRealNumberPrecision( 12 );
132 QString
x = qIsFinite(
m_x ) ? QString::number(
m_x,
'f', thePrecision ) :
QObject::tr(
"infinite" );
133 QString
y = qIsFinite(
m_y ) ? QString::number(
m_y,
'f', thePrecision ) :
QObject::tr(
"infinite" );
134 return QString(
"%1,%2" ).arg( x ).arg( y );
139 int myDegreesX = int( qAbs(
m_x ) );
140 float myFloatMinutesX = float(( qAbs(
m_x ) - myDegreesX ) * 60 );
141 int myIntMinutesX = int( myFloatMinutesX );
142 float mySecondsX = float( myFloatMinutesX - myIntMinutesX ) * 60;
144 int myDegreesY = int( qAbs(
m_y ) );
145 float myFloatMinutesY = float(( qAbs(
m_y ) - myDegreesY ) * 60 );
146 int myIntMinutesY = int( myFloatMinutesY );
147 float mySecondsY = float( myFloatMinutesY - myIntMinutesY ) * 60;
151 QString rep = QString::number( myDegreesX ) + QChar( 176 ) +
152 QString::number( myIntMinutesX ) + QString(
"'" ) +
153 QString::number( mySecondsX,
'f', thePrecision ) + QString(
"\"" ) +
154 myXHemisphere + QString(
"," ) +
155 QString::number( myDegreesY ) + QChar( 176 ) +
156 QString::number( myIntMinutesY ) + QString(
"'" ) +
157 QString::number( mySecondsY,
'f', thePrecision ) + QString(
"\"" ) +
164 int myDegreesX = int( qAbs(
m_x ) );
165 float myFloatMinutesX = float(( qAbs(
m_x ) - myDegreesX ) * 60 );
167 int myDegreesY = int( qAbs(
m_y ) );
168 float myFloatMinutesY = float(( qAbs(
m_y ) - myDegreesY ) * 60 );
172 QString rep = QString::number( myDegreesX ) + QChar( 176 ) +
173 QString::number( myFloatMinutesX,
'f', thePrecision ) + QString(
"'" ) +
174 myXHemisphere + QString(
"," ) +
175 QString::number( myDegreesY ) + QChar( 176 ) +
176 QString::number( myFloatMinutesY,
'f', thePrecision ) + QString(
"'" ) +
198 double dx = other.
x() -
m_x;
199 double dy = other.
y() -
m_y;
200 return ( atan2( dx, dy ) * 180.0 /
M_PI );
206 if ((
m_x == other.
x() ) && (
m_y == other.
y() ) )
214 if ((
m_x == other.
x() ) && (
m_y == other.
y() ) )
222 if ( &other !=
this )
241 qAbs(( b.
y() - a.
y() ) *(
m_x - a.
x() ) - (
m_y - a.
y() ) *( b.
x() - a.
x() ) )
242 >= qMax( qAbs( b.
x() - a.
x() ), qAbs( b.
y() - a.
y() ) )
247 if (( b.
x() < a.
x() && a.
x() <
m_x ) || ( b.
y() < a.
y() && a.
y() <
m_y ) )
251 if ((
m_x < a.
x() && a.
x() < b.
x() ) || (
m_y < a.
y() && a.
y() < b.
y() ) )
255 if (( a.
x() < b.
x() && b.
x() <
m_x ) || ( a.
y() < b.
y() && b.
y() <
m_y ) )
259 if ((
m_x < b.
x() && b.
x() < a.
x() ) || (
m_y < b.
y() && b.
y() < a.
y() ) )
275 t = (
m_x * ny -
m_y * nx - x1 * ny + y1 * nx ) / (( x2 - x1 ) * ny - ( y2 - y1 ) * nx );
279 minDistPoint.
setX( x1 );
280 minDistPoint.
setY( y1 );
284 minDistPoint.
setX( x2 );
285 minDistPoint.
setY( y2 );
289 minDistPoint.
setX( x1 + t *( x2 - x1 ) );
290 minDistPoint.
setY( y1 + t *( y2 - y1 ) );
293 double dist =
sqrDist( minDistPoint );