Package toxi.geom
Class Sphere
java.lang.Object
toxi.geom.Vec3D
toxi.geom.Sphere
- All Implemented Interfaces:
Comparable<ReadonlyVec3D>
,ReadonlyVec3D
,Shape3D
-
Nested Class Summary
Nested classes/interfaces inherited from class toxi.geom.Vec3D
Vec3D.Axis
-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
Earth's mean radius in km (http://en.wikipedia.org/wiki/Earth_radius#Mean_radii)float
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the point is within the given shape/volume.float[]
intersectRay
(Ray3D ray) Alternative toSphereIntersectorReflector
.boolean
intersectSphereTriangle
(Triangle3D t, Vec3D result) Considers the current vector as centre of a collision sphere with radius r and checks if the triangle abc intersects with this sphere.double
surfaceDistanceBetween
(Vec2D p, Vec2D q) Computes the surface distance on this sphere between two points given as lon/lat coordinates.Calculates the normal vector on the sphere in the direction of the current point.toMesh
(int res) Methods inherited from class toxi.geom.Vec3D
abs, add, add, add, addSelf, addSelf, addSelf, angleBetween, angleBetween, clear, compareTo, constrain, constrain, copy, cross, cross, crossInto, crossSelf, distanceTo, distanceToSquared, dot, dot, equals, equals, equalsWithTolerance, floor, frac, fromXYTheta, fromXZTheta, fromYZTheta, getAbs, getCartesian, getClosestAxis, getComponent, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getMapped, getNormalized, getNormalizedTo, getReciprocal, getReflected, getRotatedAroundAxis, getRotatedX, getRotatedY, getRotatedZ, getRoundedTo, getSignum, getSpherical, hashCode, headingXY, headingXZ, headingYZ, immutable, interpolateTo, interpolateTo, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInAABB, isInAABB, isMajorAxis, isZeroVector, jitter, jitter, jitter, jitter, jitter, jitter, limit, magnitude, magSquared, max, maxSelf, min, minSelf, modSelf, modSelf, normalize, normalizeTo, randomVector, randomVector, reciprocal, reflect, rotateAroundAxis, rotateX, rotateY, rotateZ, roundTo, scale, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, scaleSelf, set, set, set, setComponent, setComponent, setX, setXY, setY, setZ, shuffle, signum, snapToAxis, sub, sub, sub, subSelf, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, to4D, to4D, toArray, toArray4, toCartesian, toSpherical, toString, x, y, z
-
Field Details
-
EARTH_RADIUS
public static final float EARTH_RADIUSEarth's mean radius in km (http://en.wikipedia.org/wiki/Earth_radius#Mean_radii)- See Also:
-
radius
public float radius
-
-
Constructor Details
-
Sphere
public Sphere() -
Sphere
public Sphere(float radius) -
Sphere
-
Sphere
-
-
Method Details
-
containsPoint
Description copied from interface:Shape3D
Checks if the point is within the given shape/volume.- Specified by:
containsPoint
in interfaceShape3D
- Returns:
- true, if inside
-
intersectRay
Alternative toSphereIntersectorReflector
. Computes primary & secondary intersection points of this sphere with the given ray. If no intersection is found the method returns null. In all other cases, the returned array will contain the distance to the primary intersection point (i.e. the closest in the direction of the ray) as its first index and the other one as its second. If any of distance values is negative, the intersection point lies in the opposite ray direction (might be useful to know). To get the actual intersection point coordinates, simply pass the returned values toRay3D.getPointAtDistance(float)
.- Parameters:
ray
-- Returns:
- 2-element float array of intersection points or null if ray doesn't intersect sphere at all.
-
intersectSphereTriangle
Considers the current vector as centre of a collision sphere with radius r and checks if the triangle abc intersects with this sphere. The Vec3D p The point on abc closest to the sphere center is returned via the supplied result vector argument.- Parameters:
t
- triangle to check for intersectionresult
- a non-null vector for storing the result- Returns:
- true, if sphere intersects triangle ABC
-
surfaceDistanceBetween
Computes the surface distance on this sphere between two points given as lon/lat coordinates. The x component of each vector needs to contain the longitude and the y component the latitude (both in radians). Algorithm from: http://www.csgnetwork.com/gpsdistcalc.html- Parameters:
p
-q
-- Returns:
- distance on the sphere surface
-
tangentPlaneNormalAt
Calculates the normal vector on the sphere in the direction of the current point.- Parameters:
q
-- Returns:
- a unit normal vector to the tangent plane of the ellipsoid in the point.
-
toMesh
-
toMesh
-