SpatiumLib
Public Member Functions | Protected Attributes | Friends | List of all members
spatium::geom3d::Sphere Class Reference

Sphere geometry. More...

#include <Sphere.h>

Inheritance diagram for spatium::geom3d::Sphere:
Inheritance graph
[legend]
Collaboration diagram for spatium::geom3d::Sphere:
Collaboration graph
[legend]

Public Member Functions

 Sphere (const Point3 &origin, double radius)
 Constructor. More...
 
 Sphere (double radius)
 Constructor. More...
 
 Sphere (const Sphere &other)=default
 Copy constructor. More...
 
Sphereoperator= (const Sphere &other)=default
 Assignment operator. More...
 
virtual ~Sphere ()=default
 Destructor. More...
 
void origin (const Point3 &origin)
 Set origin of sphere. More...
 
Point3 origin () const
 Get origin of sphere. More...
 
void radius (double radius)
 Set radius of sphere. More...
 
double radius () const
 Get radius of sphere. More...
 
double distanceTo (const Point3 &point) const override
 Compute Euclidean distance to point. More...
 
Point3 projectPoint (const Point3 &point) const override
 Project point onto sphere. More...
 
bool intersectLine (const Point3 &origin, const Vector3 &direction, Point3 &intersection) const override
 Intersect line with sphere. More...
 
Vector3 surfaceNormal (const Point3 &point) const
 Compute surface normal at given point. More...
 
double distanceToHorizon (double height) const
 Compute distance to horizon as straight line from a point above surface to the horizon. More...
 
Point3 pointOnHorizon (const Point3 &point, double direction)
 Compute point on horizon in a given direction. More...
 
Point3 sphericalToCartesianCoordinates (double longitude, double latitude, double height)
 Compute Cartesian coordinates from spherical coordinates. More...
 
Point3 cartesianToSphericalCoordinates (double x, double y, double z)
 Compute spherical coordinates from Cartesian coordinates. Cartesian vector (-1, 0, 0) points towards origin of spherical coordinate system. More...
 
- Public Member Functions inherited from spatium::geom3d::Geometry
 Geometry ()=default
 
virtual ~Geometry ()=default
 

Protected Attributes

Point3 m_origin
 
double m_radius
 

Friends

std::ostream & operator<< (std::ostream &os, const Sphere &sphere)
 Output to ostream. More...
 

Detailed Description

Sphere geometry.

A sphere is defined by a point (origin) and a radius.

Parametric description = x^2 + y^2 + z^2 = r^2

Constructor & Destructor Documentation

◆ Sphere() [1/3]

spatium::geom3d::Sphere::Sphere ( const Point3 origin,
double  radius 
)
inline

Constructor.

◆ Sphere() [2/3]

spatium::geom3d::Sphere::Sphere ( double  radius)
inline

Constructor.

◆ Sphere() [3/3]

spatium::geom3d::Sphere::Sphere ( const Sphere other)
default

Copy constructor.

◆ ~Sphere()

virtual spatium::geom3d::Sphere::~Sphere ( )
virtualdefault

Destructor.

Member Function Documentation

◆ cartesianToSphericalCoordinates()

Point3 spatium::geom3d::Sphere::cartesianToSphericalCoordinates ( double  x,
double  y,
double  z 
)
inline

Compute spherical coordinates from Cartesian coordinates. Cartesian vector (-1, 0, 0) points towards origin of spherical coordinate system.

Parameters
[in]xX coordinate
[in]yY coordinate
[in]zZ coordinate
Returns
Point with spherical coordinates: latitude, longitude and height above surface. Latitude and longtiude are in radians.

◆ distanceTo()

double spatium::geom3d::Sphere::distanceTo ( const Point3 point) const
inlineoverridevirtual

Compute Euclidean distance to point.

Parameters
[in]pointPoint
Returns
distance to point

Implements spatium::geom3d::Geometry.

◆ distanceToHorizon()

double spatium::geom3d::Sphere::distanceToHorizon ( double  height) const
inline

Compute distance to horizon as straight line from a point above surface to the horizon.

Parameters
[in]heightHeight above surface
Returns
Straight distance to horizon Compute distance to horizon as curved line over the surface of the sphere (arc length).
Parameters
[in]heightHeight above surface
Returns
Curved distance to horizon

◆ intersectLine()

bool spatium::geom3d::Sphere::intersectLine ( const Point3 origin,
const Vector3 direction,
Point3 intersection 
) const
inlineoverridevirtual

Intersect line with sphere.

Parameters
[in]originOrigin of line
[in]directionDirection of line
[out]intersectionIntersection point
Returns
True if there is an intersection, otherwise false

Implements spatium::geom3d::Geometry.

◆ operator=()

Sphere& spatium::geom3d::Sphere::operator= ( const Sphere other)
default

Assignment operator.

◆ origin() [1/2]

void spatium::geom3d::Sphere::origin ( const Point3 origin)
inline

Set origin of sphere.

Parameters
[in]originOrigin

◆ origin() [2/2]

Point3 spatium::geom3d::Sphere::origin ( ) const
inline

Get origin of sphere.

Returns
origin

◆ pointOnHorizon()

Point3 spatium::geom3d::Sphere::pointOnHorizon ( const Point3 point,
double  direction 
)
inline

Compute point on horizon in a given direction.

Parameters
[in]pointPoint above surface
[in]directionDirection towards horizon as polar coordinate in radians. 0 = east, 1/2 pi = north, etc.

◆ projectPoint()

Point3 spatium::geom3d::Sphere::projectPoint ( const Point3 point) const
inlineoverridevirtual

Project point onto sphere.

Parameters
[in]pointPoint
Returns
Projected point

Implements spatium::geom3d::Geometry.

◆ radius() [1/2]

void spatium::geom3d::Sphere::radius ( double  radius)
inline

Set radius of sphere.

Parameters
[in]radiusRadius

◆ radius() [2/2]

double spatium::geom3d::Sphere::radius ( ) const
inline

Get radius of sphere.

Returns
radius

◆ sphericalToCartesianCoordinates()

Point3 spatium::geom3d::Sphere::sphericalToCartesianCoordinates ( double  longitude,
double  latitude,
double  height 
)
inline

Compute Cartesian coordinates from spherical coordinates.

Parameters
[in]longitudeLongitude in radians
[in]latitudeLatitude in radians
[in]heightHeight above surface
Returns
Point with cartesian x,y and z coordinates

◆ surfaceNormal()

Vector3 spatium::geom3d::Sphere::surfaceNormal ( const Point3 point) const
inline

Compute surface normal at given point.

Parameters
[in]pointPoint
Returns
Surface normal

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Sphere sphere 
)
friend

Output to ostream.

Member Data Documentation

◆ m_origin

Point3 spatium::geom3d::Sphere::m_origin
protected

◆ m_radius

double spatium::geom3d::Sphere::m_radius
protected

The documentation for this class was generated from the following file: