SPointCategoryΒΆ
scene.spad line 828 [edit on github]
PointCategory is the category of points and vectors in space. Points may be used to represent shapes in a scenegraph such as: the vertices of a cube or points along a line. Shapes such as these may be defined explicitly or may be plotted. We implement SetCategory to allow us to curry transforms from one point to another.
- *: (DoubleFloat, %) -> %
*(
s
,x
) gives scalar multiplication Although, scalar multiplication is strictly only a valid operation for vectors and not points, we allow it here because there are some useful short cuts, for instance, to find the central point between two points we can add them together and scalar multiply by 0.5.
- +: (%, %) -> %
+(
x
,y
) gives addition add the corresponding elements of the vector or point. The type (vector or point) depends on the following table: vector + vector = vector point + vector = point point + point = invalid (but interpret as vector) Although, adding two points is not strictly a valid operation, we allow it here by interpreting the point as a vector relative to the origin. We do that because there are some useful short cuts, for instance, to find the central point between two points we can add them together and scalar multiply by 0.5.
- -: (%, %) -> %
-(x, y)
gives subtraction subtract the corresponding elements of the vector or point. The type (vector or point) depends on the following table: vector - vector = vector point - vector = point vector - point = invalid (but interpret as point) point - point = invalid (but interpret as vector) Although, subtracting two points is not strictly a valid operation, we allow it here by interpreting the result as the vector distance between the two points.
- coerce: % -> OutputForm
output
- colinearity: (%, %) -> DoubleFloat
colinearity(x, y)
returns a measure of how parallel two vectors are independent of the length of the vectors: 1.0 is completely parallel 0.0 is completely perpendicular returned value will be between these
- dimension: % -> PositiveInteger
dimension(p)
returns the number of dimensions that make up the point categoryp
.
- distance: (%, %) -> DoubleFloat
distance(p1, p2)
returns the distance between the pointsp1
is the first point.p2
is the second point. There are 2 metrics associated with any SPointCategory the underlying space and the space that it is embedded in this is the distance in the underlying space.
- distanceSquared: (%, %) -> DoubleFloat
distanceSquared(p1, p2)
returns the distance between the pointsp1
andp2
. There are 2 metrics associated with any SPointCategory the underlying space and the space that it is embedded in this is the distance in the underlying space.
- extendedCoords: % -> List DoubleFloat
extendedCoords(pt)
returns extended coordinates as a list.
- inBounds?: (%, %, %) -> Boolean
inBounds?(pt, mns, mxs)
returnstrue
ifpt
is inside bounding box where bounding box is specified by min and max.
- isPoint?: % -> Boolean
isPoint?(p)
returnstrue
if this represents a point as opposed to a vector.
- isVector?: % -> Boolean
isVector? returns
true
if this represents a vector as opposed to a point.
- latex: % -> String
from SetCategory
- max: (%, %) -> %
max(a, b)
returns a point whose value in each dimension is the maximum. So if a has the largestx
value andb
has the largesty
value then the result will combine these. This is useful for constructing boundary boxes around sets of points.
- min: (%, %) -> %
min(a, b)
returns a point whose value in each dimension is the minimum. So if a has the smallestx
value andb
has the smallesty
value then the result will combine these. This is useful for constructing boundary boxes around sets of points.
- parallel: (%, %) -> DoubleFloat
parallel(x, y)
returns the length of the parallel component of two vectors. In the case of Euclidean space this is the dot product of two vectors. We use this function to test the colinearity
- perpendicular: (%, %) -> %
perpendicular(x, y)
returns a vector perpendicular to the two vectors in the case of 3D Euclidean space this is the cross the product of two vectors. We use this function to compute orthogonal
- Pnan?: % -> Boolean
Pnan?(p)
returnstrue
if any of its elements are not valid DoubleFloat values. Examples of invalid floating point numbers are when we have divided a given element by zero or taken sqrt of negative number at some stage? Note: we can still represent a point at infinity and we can represent points using complex numbers, but we do this using projective or conformal space or by using the appropriate instance of SPointCategory, not by using invalid floating point numbers.
- screenCoords: % -> List DoubleFloat
screenCoords(pt)
returns screen coordinates as a list.
- screenCoordX: % -> DoubleFloat
screenCoordX(pt)
returns the'x'
(left to right) screen coordinate.
- screenCoordY: % -> DoubleFloat
screenCoordY(pt)
returns the'y'
(bottom to top) screen coordinate.
- screenCoordZ: % -> DoubleFloat
screenCoordZ(pt)
returns the'z'
(out from screen) screen coordinate.
- sipnt: (Integer, Integer, Integer) -> %
sipnt(a, b, c)
constructs a 3D point defined by a,b
andc
of type Integer
- sivec: (Integer, Integer, Integer) -> %
sivec(a, b, c)
constructs a 3D vector defined by a,b
andc
of type Integer
- spnt: (DoubleFloat, DoubleFloat) -> %
spnt(a, b)
constructs a 2D point defined by a andb
of typeR
- spnt: (DoubleFloat, DoubleFloat, DoubleFloat) -> %
spnt(a, b, c)
constructs a 3D point defined by a,b
andc
of typeR
- svec: (DoubleFloat, DoubleFloat) -> %
svec(a, b)
constructs a 2D vector defined by a andb
of typeR
- svec: (DoubleFloat, DoubleFloat, DoubleFloat) -> %
svec(a, b, c)
constructs a 3D vector defined by a,b
andc
of typeR
- toPoint: % -> %
toPoint(p)
returns a Point with the same coordinates asp
Ifp
was originally a vector then that will be treated as the distance from the origin.
- toVector: % -> %
toVector returns
a Vector with the same coordinates asp
Ifp
was originally a point then the vector will be the distance from the origin.
- unitVector: % -> %
unitVector(p)
returns a vector with the same direction asp
but with unit length. We scale until length is 1