# Sphere

## Description

`struct` `Tinman.Core.Math.Sphere`

Represents a sphere in 3D space.

## Public / Constants

### Undefined

`public` `static` `readonly` `attribute` `Undefined` → `(Sphere)`

An undefined sphere.

### Zero

`public` `static` `readonly` `attribute` `Zero` → `(Sphere)`

A sphere with radius zero, centered at the coordinate origin.

## Public / Constructors

### Sphere

`public` `constructor` `Sphere1` → `(1)`

The sphere radius. If less than zero, the sphere will be undefined.

Creates a new instance of Sphere.

`public` `constructor` `Sphere2` → `(2)`

center in : Vec3D

The sphere center.

`[>=0]`

Creates a new instance of Sphere.

## Public / Methods

### Contains

`[Pure]`
`public` `method` `Contains1` → `(1)`

sphere in : Sphere

The sphere to test.

returns → bool

`true` if the given sphere is contained in this one,
`false` if not.

Checks if this sphere contains the given one.

`[Pure]`
`public` `method` `Contains2` → `(2)`

center in : Vec3D

Center of the sphere to test.

radius opt : float64 = 0

Radius of the sphere to test.

returns → bool

`true` if the given sphere is contained in this one,
`false` if not.

Checks if this sphere contains the given one.

### Dot

`[Pure]`
`public` `method` `Dot` → `(2)`

origin in : Vec3D

The origin point.

direction in : Vec3D

The unit-length direction vector.

returns → RangeD

The dot product range.

Computes the dot product range of this sphere.

The dot product range is defined as follows:

```dot    = dot(Center - origin, direction)
result = [-dot .. +dot]```

### Grow

`[Pure]`
`public` `method` `Grow1` → `(1)`

sphere in : Sphere

The sphere to contain.

returns → Sphere

The resulting sphere.

Grows this sphere so that it contains the given one.

If this sphere is undefined, the given sphere in will be returned.

`[Pure]`
`public` `method` `Grow2` → `(2)`

center in : Vec3D

Center of the sphere to contain.

radius opt : float64 = 0

Radius of the sphere to contain.

returns → Sphere

The resulting sphere.

Grows this sphere so that it contains the given one.

### Intersects

`[Pure]`
`public` `method` `Intersects1` → `(1)`

sphere in : Sphere

The sphere to test.

returns → bool

`true` if the given sphere intersects with this one,
`false` if not.

Checks if this sphere intersects with the given one.

`[Pure]`
`public` `method` `Intersects2` → `(2)`

center in : Vec3D

Center of the sphere to test.

radius opt : float64 = 0

Radius of the sphere to test.

returns → bool

`true` if the given sphere intersects with this one,
`false` if not.

Checks if this sphere intersects with the given one.

### Scale

`[Pure]`
`public` `method` `Scale` → `(1)`

factor in : float64

The scale factor.

returns → Sphere

The scaled sphere.

Scales this sphere.

### Translate

`[Pure]`
`public` `method` `Translate` → `(1)`

offset in : Vec3D

The translation offset.

returns → Sphere

The translated sphere.

Translates this sphere.

## Public / Attributes

### Center

`public` `readonly` `attribute` `Center` → `(Vec3D)`

The sphere center or Vec3D.Undefined if undefined.

### Is​Undefined

`public` `attribute` `IsUndefined` → `(get)`

value : bool

`true` if this sphere has an undefined value, `false` if not.

Checks if this sphere has an undefined value.

Sphere.Undefined

`public` `readonly` `attribute` `Radius` → `(float64)`

The sphere radius or Maths.NanD if undefined.

### Volume

`public` `attribute` `Volume` → `(get)`

value : float64

`[>=0]`
The sphere volume.

Returns the volume of this sphere.

## Serialization

### Serializer

`public` `static` `readonly` `attribute` `Serializer` → `(ITypeSerializer<Sphere>)`

The serialization helper object for values of Sphere.