Пример #1
0
/**
 * Exports a quadrilateral with the current attributes.
 * This is a convenience function that exports two triangles but may
 * also be re-implemented to do something else.
 */
void RExporter::exportQuad(
    const RVector& p1, const RVector& p2,
    const RVector& p3, const RVector& p4) {

    exportTriangle(RTriangle(p1, p2, p3));
    exportTriangle(RTriangle(p3, p4, p1));
}
Пример #2
0
/**
 * Maps the given WCS position to a UCS position.
 */
RVector RUcs::mapToUcs(const RVector& positionWcs) {
    // normal of UCS XY plane in WCS:
    RVector normal = getZAxisDirection();

    // a ray from the WCS position in the direction of the UCS plane normal:
    RLine ray(positionWcs, positionWcs + normal);

    // the UCS XY plane as a WCS triangle:
    RTriangle plane(origin, origin + xAxisDirection, origin + yAxisDirection);

    // the Z coordinate of the result is the distance of the given position to the
    // XY plane:
    double z = plane.getDistanceTo(positionWcs, false);

    // find intersection point of ray with XY plane:
//    QList<RVector> res = plane.getIntersectionPoints(ray, false);
    QList<RVector> res = RShape::getIntersectionPoints(plane, ray, false);
    if (res.size()==0) {
        qDebug("RUcs::mapToUcs: no intersection between plane and normal");
        return RVector();
    }

    // intersection point of ray with XY plane:
    RVector onPlane = res.front();

    // find absolute value of X as distance of given position to Y axis of this UCS:
    RLine yAxisUcs(origin, origin + yAxisDirection);
    double x = yAxisUcs.getDistanceTo(onPlane, false);

    // find absolute value of Y as distance of given position to X axis of this UCS:
    RLine xAxisUcs(origin, origin + xAxisDirection);
    double y = xAxisUcs.getDistanceTo(onPlane, false);

    // determine sign of X/Y coordinates:
    if (RTriangle(origin, origin-xAxisDirection, origin+yAxisDirection).isPointInQuadrant(onPlane)) {
        return RVector(-x, y, z);
    }
    else if (RTriangle(origin, origin-xAxisDirection, origin-yAxisDirection).isPointInQuadrant(onPlane)) {
        return RVector(-x, -y, z);
    }
    else if (RTriangle(origin, origin+xAxisDirection, origin-yAxisDirection).isPointInQuadrant(onPlane)) {
        return RVector(x, -y, z);
    }
    else {
        return RVector(x, y, z);
    }
}
Пример #3
0
RTriangle RTriangle::createArrow(const RVector& position, double direction, double arrowSize) {
    double cosv1, sinv1, cosv2, sinv2;
    double arrowSide = arrowSize/cos(0.165);

    cosv1 = cos(direction+0.165)*arrowSide;
    sinv1 = sin(direction+0.165)*arrowSide;
    cosv2 = cos(direction-0.165)*arrowSide;
    sinv2 = sin(direction-0.165)*arrowSide;

    RVector p1(position.x - cosv1, position.y - sinv1);
    RVector p2(position.x - cosv2, position.y - sinv2);

    return RTriangle(position, p1, p2);
}