Ejemplo n.º 1
0
Matrix3f BSpline2f::frameAt( float t ) const
{
    Vector2f p = evaluateAt( t );
    Vector2f tangent = tangentAt( t ).normalized();
    Vector2f normal = tangent.normal();

    return Matrix3f
    (
        normal.x, tangent.x, p.x,
        normal.y, tangent.y, p.y,
        0, 0, 1
    );
}
Ejemplo n.º 2
0
// static
std::vector< Vector2f > GeometryUtils::uniformSampleBoxAroundLineSegment( const Vector2f& p0, const Vector2f& p1,
    float width, int nSamplesWidth, int nSamplesLength )
{
    std::vector< Vector2f > samples( nSamplesWidth * nSamplesLength );

    Vector2f unitLength = ( p1 - p0 ).normalized();
    Vector2f unitWidth = unitLength.normal().normalized();
    float sampleSpacingW = width / ( nSamplesWidth - 1 );
    float sampleSpacingL = ( p1 - p0 ).norm() / ( nSamplesLength - 1 );

    Vector2f origin = p0 - 0.5f * width * unitWidth;
    for( int w = 0; w < nSamplesWidth; ++w )
    {
        for( int l = 0; l < nSamplesLength; ++l )
        {
            samples[ w * nSamplesLength + l ] =
                origin + w * sampleSpacingW * unitWidth + l * sampleSpacingL * unitLength;
        }
    }

    return samples;
}