コード例 #1
0
void EC_LINE::Apply( EDIT_POINT& aHandle )
{
    SEG main( m_constrainer.GetPosition(), m_constrainer.GetPosition() + m_line );
    SEG projection( aHandle.GetPosition(), aHandle.GetPosition() + m_line.Perpendicular() );

    if( OPT_VECTOR2I intersect = projection.IntersectLines( main ) )
        aHandle.SetPosition( *intersect );
}
コード例 #2
0
void EC_45DEGREE::Apply( EDIT_POINT& aHandle )
{
    // Current line vector
    VECTOR2I lineVector( aHandle.GetPosition() - m_constrainer.GetPosition() );
    double angle = lineVector.Angle();

    // Find the closest angle, which is a multiple of 45 degrees
    double newAngle = KiROUND( angle / ( M_PI / 4.0 ) ) * M_PI / 4.0;
    VECTOR2I newLineVector = lineVector.Rotate( newAngle - angle );

    aHandle.SetPosition( m_constrainer.GetPosition() + newLineVector );
}
コード例 #3
0
void EC_CIRCLE::Apply( EDIT_POINT& aHandle )
{
    VECTOR2I centerToEnd = m_end.GetPosition() - m_center.GetPosition();
    VECTOR2I centerToPoint = aHandle.GetPosition() - m_center.GetPosition();

    int radius = centerToEnd.EuclideanNorm();
    double angle = centerToPoint.Angle();

    VECTOR2I newLine( radius, 0 );
    newLine = newLine.Rotate( angle );

    aHandle.SetPosition( m_center.GetPosition() + newLine );
}
コード例 #4
0
void EC_HORIZONTAL::Apply( EDIT_POINT& aHandle )
{
    VECTOR2I point = aHandle.GetPosition();
    point.y = m_constrainer.GetPosition().y;
    aHandle.SetPosition( point );
}
コード例 #5
0
void EC_VERTICAL::Apply( EDIT_POINT& aHandle )
{
    VECTOR2I point = aHandle.GetPosition();
    point.x = m_constrainer.GetPosition().x;
    aHandle.SetPosition( point );
}