Exemple #1
0
tgt::mat3 Flow2D::getTransformationMatrix(const tgt::vec2& r, const float scaling) const {
    tgt::vec2 tangent = FlowMath::normalize(lookupFlow(r));
    if (tangent == tgt::vec2::zero)
        return tgt::mat3(scaling, 0.0f, 0.0f,
                         0.0f, scaling, 0.0f,
                         0.0f, 0.0f, 1.0f);

    tgt::vec2 normal(tangent.y, -tangent.x);

    if (scaling != 1.0f) {
        normal *= scaling;
        tangent *= scaling;
    }

    return tgt::mat3(normal.x, tangent.x, r.x,
        normal.y, tangent.y, r.y,
        0.0f, 0.0f, 1.0f);
}
Exemple #2
0
tgt::mat4 Flow3D::getTransformationMatrix(const tgt::vec3& r, const float scaling) const {
    const tgt::vec3& v = lookupFlow(r);
    if (v == tgt::vec3::zero)
        return tgt::mat4::identity;
    tgt::vec3 front = FlowMath::normalize(v);

    tgt::vec3 temp(0.0f, 1.0f, 0.0f);
    if (fabsf(tgt::dot(temp, front)) >= 0.99f)
        temp = tgt::vec3(0.0f, 0.0f, 1.0f);
    tgt::vec3 up = FlowMath::normalize(tgt::cross(temp, front));
    tgt::vec3 right = FlowMath::normalize(tgt::cross(front, up));

    if (scaling != 1.0f) {
        front *= scaling;
        up *= scaling;
        right *= scaling;
    }

    return tgt::mat4(right.x, up.x, front.x, r.x,
        right.y, up.y, front.y, r.y,
        right.z, up.z, front.z, r.z,
        0.0f, 0.0f, 0.0f, 1.0f);
}
Exemple #3
0
bool Flow3D::isNull(const tgt::vec3& r) const {
    return (lookupFlow(r) == tgt::vec3::zero);
}