Esempio n. 1
0
    public Sphere(TScalar radius, Vector3 <TScalar> position)
    {
        Position = position;
        Radius   = radius;

        HighestPoint = Position + (Vector3 <TScalar> .UnitY * radius);
        LowestPoint  = Position + (-Vector3 <TScalar> .UnitY * radius);
        Volume       = NumberValues.FourThirdsPi <TScalar>() * Radius.Cube();
    }
Esempio n. 2
0
    public Capsule(Vector3 <TScalar> axis, TScalar radius, Vector3 <TScalar> position)
    {
        Axis     = axis;
        Position = position;
        Radius   = radius;

        var two = NumberValues.Two <TScalar>();

        _pathLength = Vector3 <TScalar> .Length(axis);

        var twoR = Radius * two;

        Length = _pathLength + twoR;

        var halfHeight = _pathLength / two;

        ContainingRadius = halfHeight + Radius;

        var _halfPath = Vector3 <TScalar> .Normalize(axis) * halfHeight;

        _start = Position - _halfPath;
        _end   = _start + axis;

        var y = Vector3 <TScalar> .UnitY * Radius;

        if (_end.Y >= _start.Y)
        {
            HighestPoint = _end + y;
            LowestPoint  = _start - y;
        }
        else
        {
            HighestPoint = _start + y;
            LowestPoint  = _end - y;
        }

        SmallestDimension = TScalar.Min(Length, twoR);

        Volume = (TScalar.Pi * Radius * Radius * _pathLength)
                 + (NumberValues.FourThirdsPi <TScalar>() * Radius.Cube());
    }