コード例 #1
0
    Vector2 Ellipse::GetSupport(const Vector2 &direction) const
    {
        Vector2 support;

        // circle case
        if (Math::IsEqual(_dimensions.x, _dimensions.y))
        {
            float theta = direction.Angle()
                , s
                , c;

            Math::SinCos(theta, s, c);

            support.x = _dimensions.x * c;
            support.y = _dimensions.x * s;
        }
        // ellipse case
        else
        {
            float theta = direction.Angle() - _rotation
                , s
                , c;

            Math::SinCos(theta, s, c);

            support.x = _dimensions.x * c * _c - _dimensions.y * s * _s;
            support.y = _dimensions.x * c * _s + _dimensions.y * s * _c;
        }

        return _position + support;
    }