Sphere class
A class representing a sphere in 3D space.
A sphere is a set of points in 3D space that are equidistant from a given center point.
Properties:
- Radius
- Volume = (4/3) × π × r³
- Surface Area = 4 × π × r²
Example:
var sphere = Sphere(5.0);
print('Volume: ${sphere.volume()}');
print('Surface Area: ${sphere.surfaceArea()}');
- Inheritance
-
- Object
- Geometry
- SolidGeometry
- Sphere
Constructors
- Sphere(num radius, {Point? center})
- Creates a sphere with the specified radius and optional center.
- Sphere.fromSurfaceArea(double surfaceArea, {Point? center})
- Creates a sphere from a given surface area.
- Sphere.fromVolume(double volume, {Point? center})
- Creates a sphere from a given volume.
Properties
- center ↔ Point
-
The center point of the sphere.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- name ↔ String
-
The name of the geometric shape.
getter/setter pairinherited
- radius ↔ num
-
The radius of the sphere.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
area(
) → double -
Calculates the area of the geometric shape.
override
-
boundingBox(
) → BoundingBox3D -
Calculates the axis-aligned bounding box (AABB) of the 3D shape.
override
-
contains(
Point point) → bool - Checks if a point is inside the sphere.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
perimeter(
) → double -
Calculates the perimeter of the 3D geometric shape.
inherited
-
surfaceArea(
) → double -
Calculates the surface area of the sphere.
override
-
toString(
) → String -
A string representation of this object.
override
-
volume(
) → double -
Calculates the volume of the sphere.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited