Back to class index
Sphere[Class Summary]
pos
r
ctor (+4 overloads)
Translate(offset)
Transform(transform) (+3 overloads)
MinimalEnclosingAABB()[const]
MaximalContainedAABB()[const]
SetNegativeInfinity()
Volume()[const]
SurfaceArea()[const]
Diameter()[const]
Centroid()[const]
AnyPointFast()[const]
ExtremePoint(direction)[const] (+1 overload)
ProjectToAxis(...)[const]
IsFinite()[const]
IsDegenerate()[const]
SetDegenerate()
Contains(point)[const] (+11 overloads)
Distance(point)[const] (+9 overloads)
MaxDistance(point)[const]
ClosestPoint(point)[const]
Intersects(...)[const] (+11 overloads)
Enclose(point,epsilon) (+10 overloads)
ExtendRadiusToContain(point,epsilon) (+1 overload)
RandomPointInside(lcg)
RandomPointOnSurface(lcg)
Triangulate(...)[const]
ToString()[const]
SerializeToString()[const]
SerializeToCodeString()[const]
Equals(rhs,epsilon)[const]
BitEquals(other)[const]
FastEnclosingSphere(...)[static]
OptimalEnclosingSphere(...)[static] (+4 overloads)
FitThroughPoints(a,b)[static] (+2 overloads)
RandomPointInside(lcg,center,radius)[static]
RandomPointOnSurface(lcg,center,radius)[static]
RandomUnitaryFloat3(lcg)[static]
IntersectLine(...)[static]
FromString(str,outEndStr)[static] (+1 overload)

Sphere::RandomPointOnSurface

Syntax

float4 Sphere::RandomPointOnSurface(LCG &lcg); [21 lines of code]
float4 Sphere::RandomPointOnSurface(LCG &lcg, const float4 &center, float radius); [4 lines of code]

Generates a random point on the surface of this sphere.

The points are distributed uniformly. This function uses the rejection method to generate a uniform distribution of points on the surface. Therefore it is assumed that this sphere is not degenerate, i.e. it has a positive radius. A fixed number of 1000 tries is performed, after which a fixed point on the surface is returned as a fallback.

Parameters

LCG &lcgA pre-seeded random number generator object that is to be used by this function to generate random values.

See Also

class LCG, RandomPointInside(), IsDegenerate().

Work in progress:

Todo: in float4 Sphere::RandomPointOnSurface(LCG &lcg):
Add Sphere::PointOnSurface(polarYaw, polarPitch).