PlanimetryCalculus.cc 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#include "PlanimetryCalculus.h"


PlanimetryCalculus::PlanimetryCalculus()
{

}

/*!
    \fn void PlanimetryCalculus::rotatePoint(QPointF &point, double alpha)
    Rotates the \a point counter clockwisely by the angle \a alpha (in radiants).
*/
void PlanimetryCalculus::rotatePoint(QPointF &point, double alpha)
{
    double x = point.x();
    double y = point.y();

    point.setX(x*qCos(alpha) - y*qSin(alpha));
    point.setY(x*qSin(alpha) + y*qCos(alpha));
}

/*!
    \fn void PlanimetryCalculus::rotatePointDegree(QPointF &point, double alpha)
    Rotates the \a point counter clockwisely by the angle \a alpha (in degrees).
*/
void PlanimetryCalculus::rotatePointDegree(QPointF &point, double alpha)
{
    rotatePoint(point, alpha/180*M_PI);
}

/*!
    \fn PlanimetryCalculus::IntersectType PlanimetryCalculus::intersects(const Circle &circle1, const Circle &circle2)
    Returns the intersection type of the two cirles \a circle1 and \a circle2.

    \sa Circle
*/
PlanimetryCalculus::IntersectType PlanimetryCalculus::intersects(const Circle &circle1, const Circle &circle2)
{
    double r1 = circle1.radius();
    double r2 = circle2.radius();
    double d = distance(circle1.origin(), circle2.origin());

    //go on here
}

/*!
    \fn double PlanimetryCalculus::distance(const QPointF &p1, const QPointF p2)
    Calculates the distance (2-norm) between \a p1 and \a p2.
    \sa QPointF
*/
double PlanimetryCalculus::distance(const QPointF &p1, const QPointF p2)
{
    double dx = p1.x()-p2.x();
    double dy = p1.y()-p2.y();

    return qSqrt(dx*dx+dy*dy);
}

/*!
    \class PlanimetryCalculus
    \inmodule Wima

    \brief The \c PlanimetryCalculus class provides routines handy for planimetrical (2D) calculations.
*/