# The l-math Reference Manual

## Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

# The l-math Reference Manual

This is the l-math Reference Manual, version 0.4.0, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:07:06 2018 GMT+0.

Next: , Previous: , Up: Top   [Contents][Index]

# L-MATH

L-MATH is a library for performing simple linear algebra. Vector and matrix classes are available, as are simple linear interpolation functions, spline-based interpolations (Catmull-Rom and B-Spline methods), and various operations related to creating rotation matrices.

L-MATH also contains various spline implementations, including those implemented using matrices:

• Hermite curves
• Cubic Beziér curves
• Uniform, non-rational B-Splines
• Catmull-Rom splines

There are also general splines that are calculated using recurrence formulae (which is generally a more stable approach than using matrices), such as:

• General Beziér curves of arbitrary degree
• Non-Rational B-Splines, including uniform and non-uniform parametrisations.

In addition, L-MATH contains various functions for creating random data, including:

• uniformly distributed random numbers and vectors
• normal distribution of random numbers and vectors
• Perlin noise.

## Vector

Vectors can be constructed using the VECTOR and TO-VECTOR functions. VECTOR accepts a list of elements, like so:

``````(lm:vector 1 2 3) => #<L-MATH:VECTOR 1.000 2.000 3.000 >
``````

The VECTOR's dimension is defined by the number of elements in the VECTOR function's lambda list.

``````(lm:dimension (lm:vector 1 2 3 4)) => 4
``````

TO-VECTOR is intended to transform other types into the VECTOR type. At the moment it supports transforming lists and, trivially, other vector objects:

``````(lm:to-vector (list 1 2 3)) => #<L-MATH:VECTOR 1.000 2.000 3.000 >
``````

Importantly, TO-VECTOR allows the vector's length to be modified:

``````(lm:to-vector (list 1 2 3) :dimension 2) => #<L-MATH:VECTOR 1.000 2.000 >
(lm:to-vector (lm:vector 1 2) :dimension 3) => #<L-MATH:VECTOR 1.000 2.000 0.000 >
``````

Vectors can typically be represented as lists. For instance:

``````(lm:dot-product (lm:vector 1 0 1) (list 0 1 0)) => 0
``````

Various operations (listed below) are available for VECTOR objects. Many of these functions will also accept lists as VECTOR representations.

``````(lm:dimension VECTOR)
``````

Returns the VECTOR's dimension.

``````(lm:length VECTOR)
``````

Synonym for DIMENSION.

``````(lm:norm VECTOR)
``````

Returns the VECTOR's length.

``````(lm:vector= LHS RHS)
``````

Returns T iff the two vectors are equal. Internally, the VECTOR class stores the data as an array of double-floats. Because of rounding errors it is not advisable to compare floating point values exactly. VECTOR= uses the special variable equivalence-tolerance to define the tolerance within which two vectors are considered equal. equivalence-tolerance defaults to 0.0001, which should be reasonable for most applications. For example:

``````(lm:vector= (lm:vector 1 2 3) (lm:vector 1 2 3.1)) => NIL
(lm:vector= (lm:vector 1 2 3) (lm:vector 1 2 3.00001)) => T
``````
``````(lm:elt VECTOR index)
``````

Returns the element at the given index. This is also a SETFable place. VECTORs are zero based.

``````(lm:x VECTOR) (lm:y VECTOR) (lm:z VECTOR) (lm:w VECTOR)
``````

Returns the elements at indices 0, 1, 2 and 3 respectively. These are all SETFable places.

``````(lm:dot-product VECTOR)
``````

Returns the VECTOR's dot product.

``````(lm:cross-product LHS RHS)
``````

Calculates the cross product between two 3-vectors.

``````(lm:angle-between FROM-VECTOR TO-VECTOR)
``````

Returns the angle, in radians, needed to align the FROM-VECTOR with the TO-VECTOR. The angle is signed, and is a left-handed rotation. Example:

``````(lm:to-degrees (lm:angle-between (lm:vector 1 0) (lm:vector 0 1))) => 90.0d0
(lm:to-degrees (lm:angle-between (lm:vector 1 0) (lm:vector 0 -1))) => -90.0d0
``````
``````(lm:euclidean-distance LHS RHS)
``````

Calculates the Euclidean distance between two vectors or two numbers.

## Matrix

Matrices can be constructed using (lm:MAKE-MATRIX row col &key initial-elements)

``````(lm:make-matrix 2 3 :initial-elements '(1 0 0
0 1 0))
=>
#<L-MATH:MATRIX 2 x 3
1.000 0.000 0.000
0.000 1.000 0.000 >
``````

If :initial-elements isn't specified, the matrix elements are initialised to zero.

``````(lm:matrix= LHS RHS)
``````

Ensures that two matrices are numerically equivalent. All the real-valued components must be within equivalence-tolerance of each other.

``````(lm:matrix-rows MATRIX) (lm:matrix-cols MATRIX)
``````

Returns the number of rows and columns in the matrix.

``````(lm:matrix-elt MATRIX row col)
``````

Returns the element at the given row and column. MATRIX objects are zero based. This is a SETFable place.

``````(lm:make-identity SIZE)
``````

Returns a SIZE×SIZE identity matrix.

``````(lm:roll-matrix SIZE ANGLE)
``````

Returns SIZE×SIZE matrix which will rotate a post multiplied vector around the z-axis. It is a left-handed rotation. The ANGLE is given in radians. SIZE should be either 3 or 4.

``````(lm:yaw-matrix SIZE ANGLE)
``````

Returns SIZE×SIZE matrix which will rotate a post multiplied vector around the y-axis. It is a left-handed rotation. The ANGLE is given in radians. SIZE should be either 3 or 4.

``````(lm:pitch-matrix SIZE ANGLE)
``````

Returns SIZE×SIZE matrix which will rotate a post multiplied vector around the x-axis. It is a left-handed rotation. The ANGLE is given in radians. SIZE should be either 3 or 4.

``````(lm:set-rotation-naming-convention CONVENTION)
``````

Rebinds YAW-MATRIX, PITCH-MATRIX, and ROLL-MATRIX to rotate around different axes. The available conventions are provided in lm:*rotation-naming-conventions*

``````(lm:create-rotation-matrix VIEW RIGHT UP &optional (SIZE 3))
``````

Creates a rotation matrix from three vectors. VIEW is the direction that the resulting vector should be pointing along, UP is the direction upwards. RIGHT is the vector orthogonal to this. Will return a left-handed rotation matrix. SIZE is the size of the matrix, and should be either 3 or 4.

``````(lm:create-rotation-from-view VIEW WORLD-UP &optional (SIZE (length SIZE)))
``````

Given a direction to look in (VIEW), and the direction that is 'upwards' in a given coordinate system, this function creates a rotation matrix to translate into that coordinate system. This rotation is left-handed. SIZE should be either 3 or 4.

``````(lm:create-rotation-from-view-to-view FROM-VIEW TO-VIEW WORLD-UP)
``````

Creates a rotation matrix that will rotate the vector FROM-VIEW on to the vector TO-VIEW, using WORLD-UP as the coordinate system's 'upward' direction. This is a left-handed rotation. Example:

``````(let ((rotation (lm:create-rotation-from-view-to-view (lm:vector 1 0 0)
(lm:vector 0 1 0)
(lm:vector 0 0 1))))
(lm:* rotation (lm:vector 1 0 0)))
=> #<L-MATH:VECTOR 0.000 1.000 0.000 >
``````

## Interpolation

``````(lm:linear-interpolation START END T-VAL)
``````

Given two vectors (START and END), and a real valued parameter (T-VAL), this returns a vector between START and END. When T-VAL is zero, this returns START. When T-VAL is 1, this returns END. Values between 0 and 1 return vectors between START and END; values below zero return vectors "before" START; values above 1 return vectors "after" END. The value 0.5 returns the vector exactly between START and END. Example:

``````(lm:linear-interpolation (lm:vector -1 0) (lm:vector 1 0) 0.5)
=> #<L-MATH:VECTOR 0.000 0.000 >
(lm:linear-interpolation (lm:vector 0 0 0) (lm:vector 10 10 10) 2)
=> #<L-MATH:VECTOR 20.000 20.000 20.000 >
``````

This method also accepts arbitrary numbers, and will interpolate between them:

``````(lm:linear-interpolation 0 100 0.5) => 50.0
``````
``````(lm:between START END)
``````

Returns the vector exactly between the VECTORs START and END.

## General Operations

``````(lm:equivalent LHS RHS)
``````

Returns t iff the two objects are numerically equivalent. Numbers are tested using =. Real-valued objects (REAL types, VECTORs and MATRIXs) are compared to each other using a tolerance equivalence-tolerance. VECTORs and MATRIX objects are compared using VECTOR= and MATRIX=.

``````(lm:copy OBJECT)
``````

Returns a copy of the given VECTOR, MATRIX or list.

``````(lm:negate OBJECT) (lm:negate! OBJECT)
``````

Returns the arithmetic inverse of the given object. NEGATE! does so destructively. Example:

``````(lm:negate (list 1 -2 3)) => (-1 2 -3)
``````
``````(lm:to-radians ANGLE) (lm:to-degrees ANGLE)
``````

Converts from radians to degrees, and vice versa.

``````(lm:test-dimensions LHS RHS)
``````

Ensures that the two items have the same dimensions. The items may be lists, vectors or matrices in most sensible combinations. This function is useful when implementing your own operations between vectors and matrices to ensure that their dimensions agree. If they do not, a DIMENSION-ERROR condition is signalled.

## Arithmetic operations

All the general arithmetic operations are defined:

``````* (lm:+ LHS RHS)
* (lm:- LHS RHS)
* (lm:- OBJECT)
* (lm:* LHS RHS)
* (lm:/ LHS RHS)
``````

## Conditions

L-MATH-ERROR: A general condition from which all error conditions for the package inherit.

DIMENSION-ERROR: This is signalled when an operation is requested on objects whose dimensions are inappropriate.

ZERO-NORM-ERROR: This is signalled on operations which do not make sense for vectors with zero norm.

OPERATION-NOT-SUPPORTED: This is signalled when an arithmetic operation is requested on two objects for which the operation is not supported. This should usually not occur, and probably should be considered a bug if it does.

## General Comments

Both VECTOR and MATRIX classes have load forms (MAKE-LOAD-FORM). Internally, the data is stored as arrays of DOUBLE-FLOAT values.

For those operations which deal with rotations, note that rotation matrices should be post-multiplied by the vectors. The coordinate system is left-handed, as are the rotations.

## Supported Compilers

L-MATH is known to work on SBCL 1.0.29 and 1.0.55. While it should work on other compilers, this so far has not been tested. Please feel free to send in reports of which compilers you've successfully run this with, or to file bug reports where L-MATH is having problems.

## Getting and Installing

L-MATH is available from its [home page][2] at Common Lisp.net, or from its github repository. L-MATH can be installed using ASDF-INSTALL and QUICKLISP:

``````(require 'asdf-install)
(asdf-install:install 'l-math)

(quicklisp:quickload 'l-math)
``````

## Reporting Bugs

Bugs can be reported to https://github.com/TheRiver/L-MATH.

## License

See the file LICENSE for the licensing details. In brief, L-MATH is licensed under the GPL, with additional permissions giving link exceptions (aka the Classpath exception). Importantly for a Common Lisp library, this exception allows you to use this GPLed library in your application regardless of the licenses of the compiler and the other libraries you are using (as long, of course, as you satisfy those licenses).

Note that this does not remove the obligation that the rest of the GPL places on you, such as supplying the source code of this library.

[2]: http://www.common-lisp.net/projects/l-math/ "Common Lisp

Next: , Previous: , Up: Top   [Contents][Index]

## 2 Systems

The main system appears first, followed by any subsystem dependency.

Previous: , Up: Systems   [Contents][Index]

### 2.1 l-math

Author

Rudolph Neeser <rudy.neeser@gmail.com>

License

GPLv3 with Classpath Exception

Description

A simple math library focused on linear algebra.

Version

0.4.0

Source

l-math.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

## 3 Files

Files are sorted by type and then listed depth-first from the systems components trees.

Previous: , Up: Files   [Contents][Index]

### 3.1 Lisp

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.1 l-math.asd

Location

l-math.asd

Systems

l-math (system)

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.2 l-math/package.lisp

Parent

l-math (system)

Location

package.lisp

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.3 l-math/conditions.lisp

Dependency

package.lisp (file)

Parent

l-math (system)

Location

conditions.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.4 l-math/generics.lisp

Dependency

conditions.lisp (file)

Parent

l-math (system)

Location

generics.lisp

Exported Definitions
Internal Definitions

initialise-data (generic function)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.5 l-math/vector.lisp

Dependency

generics.lisp (file)

Parent

l-math (system)

Location

vector.lisp

Exported Definitions
Internal Definitions

initialise-data (method)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.6 l-math/matrix.lisp

Dependency

vector.lisp (file)

Parent

l-math (system)

Location

matrix.lisp

Exported Definitions
Internal Definitions

initialise-data (method)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.7 l-math/tests.lisp

Dependency

matrix.lisp (file)

Parent

l-math (system)

Location

tests.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.8 l-math/vector-operations.lisp

Dependency

tests.lisp (file)

Parent

l-math (system)

Location

vector-operations.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.9 l-math/operations.lisp

Dependency

vector-operations.lisp (file)

Parent

l-math (system)

Location

operations.lisp

Exported Definitions
• * (function)
• + (function)
• - (function)
• / (function)
• c* (generic function)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c* (method)
• c+ (generic function)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c+ (method)
• c- (generic function)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c- (method)
• c/ (generic function)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
• c/ (method)
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.10 l-math/rotations.lisp

Dependency

operations.lisp (file)

Parent

l-math (system)

Location

rotations.lisp

Exported Definitions
Internal Definitions

fill-row (macro)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.11 l-math/scale.lisp

Dependency

rotations.lisp (file)

Parent

l-math (system)

Location

scale.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.12 l-math/translation.lisp

Dependency

scale.lisp (file)

Parent

l-math (system)

Location

translation.lisp

Exported Definitions

create-translation-matrix (function)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.13 l-math/utility.lisp

Dependency

translation.lisp (file)

Parent

l-math (system)

Location

utility.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.14 l-math/interpolate.lisp

Dependency

utility.lisp (file)

Parent

l-math (system)

Location

interpolate.lisp

Exported Definitions
Internal Definitions

private-bilinear-interpolation (function)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.15 l-math/random.lisp

Dependency

interpolate.lisp (file)

Parent

l-math (system)

Location

random.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.16 l-math/basis.lisp

Dependency

random.lisp (file)

Parent

l-math (system)

Location

basis.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.17 l-math/spline.lisp

Dependency

basis.lisp (file)

Parent

l-math (system)

Location

spline.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.18 l-math/spline-interpolation.lisp

Dependency

spline.lisp (file)

Parent

l-math (system)

Location

spline-interpolation.lisp

Exported Definitions

Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.19 l-math/transform.lisp

Dependency
Parent

l-math (system)

Location

transform.lisp

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

## 4 Packages

Packages are listed by definition order.

Next: , Previous: , Up: Packages   [Contents][Index]

### 4.1 l-math-asdf

Source

l-math.asd

Use List
• asdf/interface
• common-lisp

Previous: , Up: Packages   [Contents][Index]

### 4.2 l-math

Source

package.lisp (file)

Nickname

lm

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

## 5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.

Next: , Previous: , Up: Definitions   [Contents][Index]

### 5.1 Exported definitions

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.1 Special variables

Special Variable: *equivalence-tolerance*

When objects are closer than this distance, they are considered equivalent.

Package
Source

generics.lisp (file)

Special Variable: *rotation-naming-conventions*

Defines the various mappings possible between ROLL-MATRIX, PITCH-MATRIX, YAW-MATRIX, and the different axes.

Package
Source

rotations.lisp (file)

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.2 Macros

Macro: do-each-matrix-element (SYMBOL MATRIX &optional ROW-INDEX-SYMBOL COL-INDEX-SYMBOL) &body BODY

Iterates over each of the matrix elements, row by row.

Package
Source

matrix.lisp (file)

Macro: do-each-matrix-element-2 (LHS-SYMBOL RHS-SYMBOL LHS-MATRIX RHS-MATRIX &key TRANSPOSE-RHS) &body BODY
Package
Source

matrix.lisp (file)

Macro: do-each-vector-element (ELEMENT VECTOR &key INDEX-SYMBOL) &body BODY

Iterates over elements in a vector.

Package
Source

vector.lisp (file)

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.3 Functions

Function: * &rest ITEMS
Package
Source

operations.lisp (file)

Function: + &rest ITEMS
Package
Source

operations.lisp (file)

Function: - &rest ITEMS
Package
Source

operations.lisp (file)

Function: / &rest ITEMS
Package
Source

operations.lisp (file)

Function: b-spline-basis KNOT-DATA DEGREE FAMILY PARAMETER &key OFFSET FAST-SPLINE-INDEX

Ask for the value of a given basis function. This is based on
Farin’s ’Curves and Surfaces for Computer Aided Geometric Design. DEGREE is the degree of the curve.

This has some pre-calculated basis functions for uniform knot
secquences. You can access these by specifying an index using
FAST-SPLINE-INDEX. This is an integer between 0 and DEGREE, and
specifies which of the basis functions should be called.

Package
Source

basis.lisp (file)

Function: binomial-coefficient N I

Calculates the binomial coefficients. n and i must be non-negative.

Package
Source

utility.lisp (file)

Function: create-bernstein-polynomial N I

Returns a bernstein polynomial for n and i. This returned function takes one parameter.

Package
Source

utility.lisp (file)

Function: create-rotation-from-view VIEW WORLD-UP &optional SIZE

Given a direction to look in (VIEW), and the direction that is ’upwards’ in a given coordinate system, this function creates a rotation matrix to translate into that coordinate system. This matrix should be post multiplied by any vectors. The matrix is defined using a left-handed coordinate system.

Package
Source

rotations.lisp (file)

Function: create-rotation-from-view-to-view FROM-VIEW TO-VIEW WORLD-UP

Creates a rotation matrix that will rotate the vector FROM-VIEW on to the vector TO-VIEW, using WORLD-UP as the coordinate system’s ’upward’ direction. This matrix should be post-multiplied by any vectors.

Package
Source

rotations.lisp (file)

Function: create-rotation-matrix VIEW RIGHT UP &optional SIZE

Creates a rotation matrix from three vectors. VIEW is the direction that the object should be pointing along, UP is the direction upwards. RIGHT is the vector orthogonal to this.

Package
Source

rotations.lisp (file)

Function: create-scale-matrix SCALE-LIST &key HOMOGENOUS

Given a list of scales, one for each dimension, this returns a matrix that will scale any post multiplied vectors by the appropriate amount in each dimension.

Package
Source

scale.lisp (file)

Function: create-translation-matrix TRANSLATIONS

Given a list of translation, this returns a (1+ (length translations)) × (1+ (length translations)) matrix that will translate any post multiplied vector by the given amount in each dimension. This is a matrix that operates in homogenous coordinates.

Package
Source

translation.lisp (file)

Function: create-uniform-scale-matrix DIMENSION SCALE &key HOMOGENOUS

Creates a matrix that will scale all elements uniformly. Post multiply this matrix by the vectors.

Package
Source

scale.lisp (file)

Function: draw-noise3-output WIDTH HEIGHT FILE-PATH &optional PLANE-WIDTH

Outputs perlin noise in the PPM format. WIDTH and HEIGHT are the resolution of the image. FILE-PATH defines where the image should be saved, and PLANE-WIDTH defines the width of the plane on which the noise is added. The wider this width, the smaller the noise detail.

Package
Source

random.lisp (file)

Function: evaluate-bernstein-polynomial N I T-VAL

Evaluates the bernstein polygnomial for n and i at t-val. If this polynomial will be used multiple times, it might be more efficient to create it using CREATE-BERNSTEIN-POLYNOMIAL.

Package
Source

utility.lisp (file)

Function: factorial N

Calculates the factorial of the integer, n. The factorial is the product of the sequence of integers 1, 2, 3, ..., n. n must not be a negative number. The factorial of n = 0 is defined to be 1.

Package
Source

utility.lisp (file)

Function: initialize-noise3 &key LOOKUP-SIZE

Initialises the perlin noise function, NOISE3. This will be called automatically by NOISE3 if it has not already been done so. You usually will not have to call this function. If you wish to change the random data which NOISE3 uses to calculate the perlin noise, then call this function. LOOKUP-SIZE determines the amount of data stored to calculate the perlin noise. You will probably not have to change this from the default value.

Package
Source

random.lisp (file)

Function: make-diagonal DIAGONAL

Creates a (length diagonal) × (length diagonal) matrix zero everywhere except along the diagonal.

Package
Source

matrix.lisp (file)

Function: make-identity SIZE

Creates an size x size identity matrix.

Package
Source

matrix.lisp (file)

Function: make-knots KNOTS &key MULTIPLICITY ADD-PHANTOMS

Creates a knot sequence. Notice that this will add some phantom knots to the beginning and end of the sequence, unless ADD-PHANTOMS is false. If MULTIPLICITY, a list of multiplicity values, is not given, each knot is assumed to be a simple (non-repeated) knot.

Package
Source

basis.lisp (file)

Function: make-matrix ROWS COLS &key INITIAL-ELEMENTS

Creates a matrix of the given dimensions.

Package
Source

matrix.lisp (file)

Function: make-random-vector DIMENSION &key NOISE

Creates a VECTOR of the given dimension filled with random values obtained by calling NOISE once for each element in the VECTOR. By default, this uses normally distributed random numbers with a mean of 0 and standard deviation of 1.

Package
Source

random.lisp (file)

Function: make-vector DIM &key INITIAL-ELEMENTS

Create a vector of the given dimensions.

Package
Source

vector.lisp (file)

Function: noise3 POINT

Calculates Perlin noise. As input, it takes a 3-vector. It returns a random value between -1 and 1.

Package
Source

random.lisp (file)

Function: normal &key MEAN SD MIN MAX STATE

Returns a normally distributed random variable with the given mean and standard-deviation. If min or max is given, the random number is no smaller than min and no larger than max.

Package
Source

random.lisp (file)

Function: pitch-by VECTOR ANGLE

Returns the given vector after it has undergone a pitch by the given angle, specified in radians. This is a left-handed rotation.

Package
Source

rotations.lisp (file)

Function: pitch-matrix SIZE ANGLE

A synonym for ROTATION-X, although this can be changed using lm:SET-ROTATION-NAMING-CONVENTION.

Package
Source

rotations.lisp (file)

Function: roll-by VECTOR ANGLE

Returns the given vector after it has undergone a roll by the given angle, specified in radians. This is a left-handed rotation.

Package
Source

rotations.lisp (file)

Function: roll-matrix SIZE ANGLE

A synonym for ROTATION-Z, although this can be changed using lm:SET-ROTATION-NAMING-CONVENTION.

Package
Source

rotations.lisp (file)

Function: rotation-x SIZE ANGLE

Creates a matrix that rotates around the x-axis by the given angle, given in radians. This is a left-handed rotation.

Package
Source

rotations.lisp (file)

Function: rotation-y SIZE ANGLE

Creates a matrix that rotates around the y-axis by the given angle, given in radians. This is a left-handed rotation

Package
Source

rotations.lisp (file)

Function: rotation-z SIZE ANGLE

Creates a matrix that rotates around the z-axis by the given angle, in radians. This is a left-handed rotation.

Package
Source

rotations.lisp (file)

Function: set-rotation-naming-convention CONVENTION

Changes the mappings between ROLL-MATRIX, PITCH-MATRIX and YAW-MATRIX and the axes. See lm:*rotation-naming-conventions* to see what conventions are possible.

Package
Source

rotations.lisp (file)

Function: summation-transformer ADDITIVE-TERM &rest OTHER-TERMS

Returns a function that will add the additive-term, and all the other-terms, to its argument. It is useful for translating objects, since that is merely an addition of a vector term.

Package
Source

transform.lisp (file)

Function: to-degrees RADIANS
Package
Source

rotations.lisp (file)

Function: to-radians DEGREES
Package
Source

rotations.lisp (file)

Function: uniform &key MIN MAX STATE

Returns a random number uniformly distributed between
minimum (inclusive) and maximum (exclusive). Like CL:RANDOM, the type of the returned value depends on the type of min and max.

Package
Source

random.lisp (file)

Function: vector &rest ELEMENTS

Create a vector.

Package
Source

vector.lisp (file)

Function: yaw-by VECTOR ANGLE

Returns the given vector after it has undergone a yaw by the given angle, specified in radians. This is a left-handed rotation.

Package
Source

rotations.lisp (file)

Function: yaw-matrix SIZE ANGLE

A synonym for ROTATION-Y, although this can be changed using lm:SET-ROTATION-NAMING-CONVENTION.

Package
Source

rotations.lisp (file)

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.4 Generic functions

Generic Function: all-knots KNOTS

Given a knots data structure, this will return a list of all knots, including multiplicities.

Package
Source

basis.lisp (file)

Methods
Method: all-knots (SPLINE b-spline)

Returns a list of all the knots (repeated if necessary for multiplicity) of the b-spline

Source

spline.lisp (file)

Method: all-knots (KNOTS-DATA b-spline-knots)
Generic Function: angle-between FROM TO

Returns the angle between two vectors. The angle is
in radians, and is signed. The angle represents the the angle needed to transform the FROM vector to the TO vector.

Package
Source

vector-operations.lisp (file)

Methods
Method: angle-between (FROM vector) (TO vector)
Generic Function: b-spline-degree OBJECT
Generic Function: (setf b-spline-degree) NEW-VALUE OBJECT
Package
Methods
Method: b-spline-degree (B-SPLINE b-spline)
Method: (setf b-spline-degree) NEW-VALUE (B-SPLINE b-spline)

The degree of the b-spline. This defaults to cubic.

Source

spline.lisp (file)

Generic Function: b-spline-knots OBJECT
Generic Function: (setf b-spline-knots) NEW-VALUE OBJECT
Package
Methods
Method: b-spline-knots (B-SPLINE b-spline)
Method: (setf b-spline-knots) NEW-VALUE (B-SPLINE b-spline)

A structure detailing the spline’s knots.

Source

spline.lisp (file)

Generic Function: b-spline-points OBJECT
Generic Function: (setf b-spline-points) NEW-VALUE OBJECT
Package
Methods
Method: b-spline-points (B-SPLINE b-spline)
Method: (setf b-spline-points) NEW-VALUE (B-SPLINE b-spline)

A list of points used defining the b-spline polygon.

Source

spline.lisp (file)

Generic Function: basis-matrix OBJECT
Generic Function: (setf basis-matrix) NEW-VALUE OBJECT
Package
Methods
Method: basis-matrix (MATRIX-SPLINE matrix-spline)
Method: (setf basis-matrix) NEW-VALUE (MATRIX-SPLINE matrix-spline)

Defines the behaviour of the
spline. For possible bases to use, see MAKE-HERMITE-BASIS-MATRIX, MAKE-BEZIER-BASIS-MATRIX, and MAKE-UNIFORM-NONRATIONAL-BSPLINE-BASIS-MATRIX

Source

spline.lisp (file)

Generic Function: between START END

Calculates the vector half way between two other
vectors. This is equivalent to (LINEAR-INTERPOLATION START END 0.5).

Package
Source

interpolate.lisp (file)

Methods
Method: between START END
Generic Function: bilinear-interpolation TOP-LEFT BOTTOM-LEFT TOP-RIGHT BOTTOM-RIGHT PARAMETER

Performs bilinear interpolation: first this
performs linear interpolation between the TOP-LEFT and BOTTOM-LEFT, as well as TOP-RIGHT and BOTTOM-RIGHT, using the y coordinate of the parameter. It then performs linear interpolation between these obtained values using the parameter’s x coordinate. The four position vectors can be of any dimension, but must all be of the same dimension. The paramater must be a 2-vector. Parameter
(0, 0) maps to the upper left corner, and (1, 1) maps to the lower right corner.

Package
Source

interpolate.lisp (file)

Methods
Method: bilinear-interpolation (TOP-LEFT vector) (BOTTOM-LEFT vector) (TOP-RIGHT vector) (BOTTOM-RIGHT vector) PARAMETER
Method: bilinear-interpolation (TOP-LEFT number) (BOTTOM-LEFT number) (TOP-RIGHT number) (BOTTOM-RIGHT number) PARAMETER
Generic Function: c* LHS RHS

multiplies two objects together.

Package
Source

operations.lisp (file)

Methods
Method: c* (LHS matrix) (RHS matrix)
Method: c* (LHS vector) (RHS matrix)
Method: c* (LHS matrix) (RHS vector)
Method: c* (LHS list) RHS

Converts lists to vectors when performing mixed type operations.

Method: c* LHS (RHS list)

Converts lists to vectors when performing mixed type operations.

Method: c* (LHS list) (RHS list)
Method: c* (LHS vector) (RHS vector)
Method: c* LHS RHS
Method: c* (LHS number) (RHS number)
Method: c* (LHS number) (RHS vector)
Method: c* (LHS number) (RHS list)
Method: c* (LHS vector) (RHS number)
Method: c* (LHS list) (RHS number)
Method: c* (LHS number) (RHS matrix)
Method: c* (LHS matrix) (RHS number)
Generic Function: c+ LHS RHS

Adds two objects together.

Package
Source

operations.lisp (file)

Methods
Method: c+ (LHS list) RHS

Converts lists to vectors when performing mixed type operations.

Method: c+ LHS (RHS list)

Converts lists to vectors when performing mixed type operations.

Method: c+ (LHS list) (RHS list)
Method: c+ (LHS vector) (RHS vector)
Method: c+ LHS RHS
Method: c+ (LHS number) (RHS number)
Method: c+ (LHS number) (RHS vector)
Method: c+ (LHS vector) (RHS number)
Method: c+ (LHS number) (RHS list)
Method: c+ (LHS list) (RHS number)
Method: c+ (LHS number) (RHS matrix)
Method: c+ (LHS matrix) (RHS number)
Generic Function: c- LHS RHS

Subtracts objects.

Package
Source

operations.lisp (file)

Methods
Method: c- (LHS list) RHS

Converts lists to vectors when performing mixed type operations.

Method: c- LHS (RHS list)

Converts lists to vectors when performing mixed type operations.

Method: c- (LHS list) (RHS list)
Method: c- (LHS vector) (RHS vector)
Method: c- LHS RHS
Method: c- (LHS number) (RHS number)
Method: c- (LHS number) (RHS vector)
Method: c- (LHS vector) (RHS number)
Method: c- (LHS number) (RHS list)
Method: c- (LHS list) (RHS number)
Method: c- (LHS number) (RHS matrix)
Method: c- (LHS matrix) (RHS number)
Generic Function: c/ LHS RHS

Divides two objects.

Package
Source

operations.lisp (file)

Methods
Method: c/ (LHS list) RHS

Converts lists to vectors when performing mixed type operations.

Method: c/ LHS (RHS list)

Converts lists to vectors when performing mixed type operations.

Method: c/ (LHS list) (RHS list)
Method: c/ (LHS vector) (RHS vector)
Method: c/ LHS RHS
Method: c/ (LHS number) (RHS number)
Method: c/ (LHS number) (RHS vector)
Method: c/ (LHS number) (RHS list)
Method: c/ (LHS vector) (RHS number)
Method: c/ (LHS list) (RHS number)
Method: c/ (LHS number) (RHS matrix)
Method: c/ (LHS matrix) (RHS number)
Generic Function: centre-of-mass VECTOR &rest VECTORS

Calculates the centre point of a series of objects.

Package
Source

vector-operations.lisp (file)

Methods
Method: centre-of-mass (VECTOR vector) &rest VECTORS
Method: centre-of-mass (NUMBER number) &rest NUMBERS

Calculates the average of a list of numbers.

Generic Function: coefficient-matrix CURVE

Returns a list of coefficient matrices for the
polynomials that control the curve along each segment. The first column of each matrix contains the coefficients for the polynomial calculating the x coefficients (row 1 is the cubic coefficient, row 2 the quadratic coefficient, row 3 the linear coefficient, and row 4 the constant). Column 2 does the same for the y polynomial coefficients, and column 3 for the z coefficients.

Package
Source

spline.lisp (file)

Methods
Method: coefficient-matrix (SPLINE matrix-spline)
Generic Function: copy ITEM

Returns a copy of the given item.

Package
Source

generics.lisp (file)

Methods
Method: copy (MATRIX matrix)
Source

matrix.lisp (file)

Method: copy (VECTOR vector)

Returns a copy of a VECTOR, just as COPY-VECTOR does.

Source

vector.lisp (file)

Method: copy (ITEM list)

Returns a copy of a list.

Generic Function: copy-vector VECTOR

Returns a copy of the original vector

Package
Source

vector.lisp (file)

Methods
Method: copy-vector (VECTOR vector)
Generic Function: cross-product LHS RHS

Calculates the cross product between 3-vectors

Package
Source

vector-operations.lisp (file)

Methods
Method: cross-product (LHS vector) (RHS vector)
Generic Function: dimension OBJECT

Returns the dimensions of a given object.

Package
Source

generics.lisp (file)

Methods
Method: dimension (MATRIX matrix)

Returns a list giving the number of rows and columns in the matrix.

Source

matrix.lisp (file)

Method: dimension (VECTOR list)

Returns the dimension of a vector represented as a list.

Source

vector.lisp (file)

Method: dimension (VECTOR vector)

Returns the dimension of a vector.

Source

vector.lisp (file)

Generic Function: domain-knots SPLINE

Returns a list of the domain knots of the
spline (the knots over which the spline is defined). These are repeated for multiplicities.

Package
Source

spline.lisp (file)

Methods
Method: domain-knots (SPLINE b-spline)
Generic Function: dot-product LHS RHS

Calculates the dot product between two vectors.

Package
Source

vector-operations.lisp (file)

Methods
Method: dot-product (LHS vector) (RHS vector)
Method: dot-product (LHS list) (RHS vector)
Method: dot-product (LHS vector) (RHS list)
Method: dot-product (LHS list) (RHS list)
Generic Function: elt VECTOR INDEX

Returns the element of a VECTOR at the given index.

Package
Source

vector.lisp (file)

Setf Expander

(setf elt) (setf expander)

Methods
Method: elt (VECTOR vector) (INDEX integer)
Method: elt (VECTOR list) (INDEX integer)
Setf Expander: (setf elt) VECTOR INDEX
Package
Source

vector.lisp (file)

Reader

elt (generic function)

Generic Function: equivalent LHS RHS

Returns t iff the two objects are numerically the same. Real valued objects are always compared using *equivalence-tolerance*.

Package
Source

generics.lisp (file)

Methods
Method: equivalent (LHS matrix) (RHS matrix)

Synonym for MATRIX=

Source

matrix.lisp (file)

Method: equivalent (LHS vector) (RHS list)
Source

vector.lisp (file)

Method: equivalent (LHS list) (RHS vector)

Compares a list and a vector for equivalence.

Source

vector.lisp (file)

Method: equivalent (LHS list) (RHS list)

Returns t iff the two lists are of the same length with equivalent elements.

Source

vector.lisp (file)

Method: equivalent (LHS vector) (RHS vector)

Synonym for VECTOR=.

Source

vector.lisp (file)

Method: equivalent LHS RHS

A default implementation that ensures that unrelated objects are not considered equivalent.

Method: equivalent (LHS number) (RHS number)

Returns t iff two numbers are equivalent (using =).

Method: equivalent (LHS real) (RHS real)

Two real values are compared for equivalence to a pre-defined tolerance.

Generic Function: euclidean-distance LHS RHS

Calculates the Euclidean distance between two objects.

Package
Source

vector-operations.lisp (file)

Methods
Method: euclidean-distance (LHS number) (RHS number)

Calculates the Euclidean distance between two numbers.

Method: euclidean-distance (LHS list) (RHS list)

Calculates the Euclidean distance between two vectors, represented as lists.

Method: euclidean-distance (LHS vector) (RHS vector)

Calculates the Euclidean distance between two vectors.

Generic Function: evaluate SPLINE PARAMETER

Evaluate the given spline at the given parameter value. Returns a point on that spline.

Package
Source

spline.lisp (file)

Methods
Method: evaluate (SPLINE b-spline) (PARAMETER number)
Method: evaluate (SPLINE bezier-curve) (T-VAL real)

Evaluates the given bezier curve at the given parameter value.

Method: evaluate (SPLINE matrix-spline) (PARAMETER real)

Evaluates the given spline at the parameter.

Generic Function: knots OBJECT
Generic Function: (setf knots) NEW-VALUE OBJECT
Package
Methods
Method: knots (B-SPLINE-KNOTS b-spline-knots)
Method: (setf knots) NEW-VALUE (B-SPLINE-KNOTS b-spline-knots)

An ascending collection of knots, stored with repetition.

Source

basis.lisp (file)

Method: (setf knots) ITEM (KNOT-DATA b-spline-knots) after
Source

basis.lisp (file)

Generic Function: length VECTOR

An alias for DIMENSION

Package
Source

vector.lisp (file)

Methods
Method: length (ARRAY simple-array)
Method: length VECTOR
Generic Function: linear-interpolation START END T-VAL

Interpolates between two points, using the
parametric line equation. START and END are the two endpoints of a line. While T-VAL takes values between 0 and 1, inclusive, the returned points will lie between these two points. No matter the value of T-VAL, the returned point will always be on the line, but will be outside of the [start, end] line segment if T-VAL is not on the domain [0, 1]

Package
Source

interpolate.lisp (file)

Methods
Method: linear-interpolation START END (T-VAL real)
Method: linear-interpolation (START number) (END number) (T-VAL real)
Generic Function: matrix-cols MATRIX

Returns the number of columns in a matrix.

Package
Source

matrix.lisp (file)

Methods
Method: matrix-cols (MATRIX matrix)
Generic Function: matrix-elt MATRIX ROW COL

Return the matrix componenent at the given row and column

Package
Source

matrix.lisp (file)

Setf Expander

(setf matrix-elt) (setf expander)

Methods
Method: matrix-elt (MATRIX matrix) (ROW integer) (COL integer)
Setf Expander: (setf matrix-elt) MATRIX ROW COL
Package
Source

matrix.lisp (file)

Reader

matrix-elt (generic function)

Generic Function: matrix-rows MATRIX

Return the number of rows in a matrix.

Package
Source

matrix.lisp (file)

Methods
Method: matrix-rows (MATRIX matrix)
Generic Function: matrix= LHS RHS

Returns t iff the two matrices are equal. Effected by *equivalence-tolerance*.

Package
Source

matrix.lisp (file)

Methods
Method: matrix= (LHS matrix) (RHS matrix)
Generic Function: maximum-parameter SPLINE

Returns the maximum value that the spline parameter may take.

Package
Source

spline.lisp (file)

Methods
Method: maximum-parameter (SPLINE b-spline)
Method: maximum-parameter (SPLINE bezier-curve)
Method: maximum-parameter (SPLINE matrix-spline)
Generic Function: minimum-parameter SPLINE

Returns the minimum value that the spline parameter may take.

Package
Source

spline.lisp (file)

Methods
Method: minimum-parameter (SPLINE b-spline)
Method: minimum-parameter (SPLINE bezier-curve)
Method: minimum-parameter (SPLINE matrix-spline)
Generic Function: multiplicity OBJECT
Generic Function: (setf multiplicity) NEW-VALUE OBJECT
Package
Methods
Method: multiplicity (B-SPLINE-KNOTS b-spline-knots)
Method: (setf multiplicity) NEW-VALUE (B-SPLINE-KNOTS b-spline-knots)

The multiplicity of the above knots.

Source

basis.lisp (file)

Method: (setf multiplicity) ITEM (KNOT-DATA b-spline-knots) after
Source

basis.lisp (file)

Generic Function: negate ITEM

Returns an item with all of its elements negated. This is non-destructive.

Package
Source

generics.lisp (file)

Methods
Method: negate (MATRIX matrix)

Returns the additive inverse of a matrix.

Source

matrix.lisp (file)

Method: negate (VECTOR list)

Non-destructively returns the additive inverse of the list, as if it were a vector.

Source

vector.lisp (file)

Method: negate (VECTOR vector)

Non-destructively returns the additive inverse of a vector.

Source

vector.lisp (file)

Method: negate (ITEM number)

Returns the additive inverse of all basic Common Lisp numbers. This is just a shortcut for using the cl:- function.

Generic Function: negate! ITEM

Returns the additive inverse of an item, much like NEGATE, only this version is destructive.

Package
Source

generics.lisp (file)

Methods
Method: negate! (MATRIX matrix)

Sets the matrix to its additive inverse and returns it.

Source

matrix.lisp (file)

Method: negate! (VECTOR list)

Destructively returns the additive inverse of the given list.

Source

vector.lisp (file)

Method: negate! (VECTOR vector)

Destructively returns the additive inverse of a vector.

Source

vector.lisp (file)

Generic Function: norm VECTOR

The distance of the vector from zero.

Package
Source

vector.lisp (file)

Methods
Method: norm (VECTOR vector)
Method: norm (VECTOR list)
Generic Function: normalise VECTOR

Returns a normalised version of the vector.

Package
Source

vector.lisp (file)

Methods
Method: normalise (VECTOR vector)
Method: normalise (VECTOR list)

Returns the normalised version of a vector represented as a list.

Generic Function: normalise! VECTOR

Destructively normalises the vector.

Package
Source

vector.lisp (file)

Methods
Method: normalise! (VECTOR vector)
Method: normalise! (VECTOR list)

Destructively updates the vector, represented as a list, into its normalised version.

Generic Function: set-spline-geometry SPLINE GEOMETRY

Set the control geometry (end points, tangents, etc.) of the given spline.

Package
Source

spline.lisp (file)

Setf Expander

(setf spline-geometry) (setf expander)

Methods
Method: set-spline-geometry (SPLINE b-spline) (GEOMETRY list)

A list of points defining the spline’s b-spline polygon.

Method: set-spline-geometry (SPLINE bezier-curve) (GEOMETRY list)

A list of points defining the bézier curve’s geometry. For a curve of degree n, there should be n+1 points.

Method: set-spline-geometry (SPLINE three-shared-spline) (LIST list)

A list of points making up the spline geometry, in order of occurance.

Method: set-spline-geometry (SPLINE last-shared-spline) (LIST list)

Sets the control geometry of the hermite curve and bézier
curves.

For hermite curves, this list should contain at least 4
elements, and should be laid out in the following manner, where Pn represents the nth point, and a(Pn) represents the tangent leading away from that point, and b(Pn) represents the tangent leading towards that point.

P1 a(P1) b(P2) P2 a(P2) b(P3) P3 a(P3) ... b(Pn-1) Pn-1 a(Pn-1) b(Pn) Pn

For bézier curves, this should be a sequence of control points:

P1 P2 P3 P4 P5 ... Pn

Both the points and the tangents should be 3-vectors.

Generic Function: spline-geometry SPLINE

Returns the geometry of the associated
spline. These are the end points, tangents, and so on, of the various splines.

Package
Source

spline.lisp (file)

Setf Expander

(setf spline-geometry) (setf expander)

Methods
Method: spline-geometry (SPLINE b-spline)
Method: spline-geometry (SPLINE bezier-curve)
Method: spline-geometry (SPLINE three-shared-spline)

Returns the list of geometry making up the spline.

Method: spline-geometry (SPLINE last-shared-spline)

Returns a list of the geometry that made up the spline.

Setf Expander: (setf spline-geometry) SPLINE GEOMETRY
Package
Source

spline.lisp (file)

Reader

spline-geometry (generic function)

Writer

set-spline-geometry (generic function)

Generic Function: spline-interpolation POINTS &key DEGREE PARAMETRISATION CLOSE

Returns a b-spline that interpolates the given
points. This is based on the discussion in sections 9.1 and 7.8 of Farin’s Curves and Surfaces for Computer Aided Geometric Design. PARAMETRISATION should be one of :uniform, :centripetal, or :chord-length. If CLOSE is true, then this will produce a closed b-spline.

Package
Source
Methods
Method: spline-interpolation (POINTS list) &key DEGREE PARAMETRISATION CLOSE
Generic Function: test-dimensions LHS RHS &key TRANSPOSE-RHS BOTH &allow-other-keys

Throws an error if the two objects do not agree in
dimensions. If the second object is a matrix, it is possible to transpose the dimensions that are tested using the :transpose-rhs argument.

Package
Source

tests.lisp (file)

Methods
Method: test-dimensions (LHS matrix) (RHS matrix) &key TRANSPOSE-RHS BOTH
Method: test-dimensions (LHS list) (RHS matrix) &key
Method: test-dimensions (LHS matrix) (RHS list) &key
Method: test-dimensions (LHS vector) (RHS matrix) &key
Method: test-dimensions (LHS matrix) (RHS vector) &key
Method: test-dimensions (VECTOR list) (DIMENSION number) &key

Ensure that the given vector has the specified dimension.

Method: test-dimensions (LHS list) (RHS list) &key
Method: test-dimensions (VECTOR vector) (DIMENSION number) &key

Ensure that the given vector has the specified dimension.

Method: test-dimensions (LHS vector) (RHS vector) &key
Generic Function: to-homogenous ITEM

Takes an item and lifts it into homogenous space by adding one dimension on to it.

Package
Source

generics.lisp (file)

Methods
Method: to-homogenous (ITEM vector)

Adds the element 1 to the end of the list.

Source

vector.lisp (file)

Method: to-homogenous (ITEM list)

Adds the element 1 to the end of the list.

Source

vector.lisp (file)

Generic Function: to-list ITEM

Returns a representation of the given object as a list.

Package
Source

generics.lisp (file)

Methods
Method: to-list (VECTOR vector)

Transforms a vector object into a list.

Source

vector.lisp (file)

Method: to-list (ITEM list)

The list representation of a list is just the list itself.

Generic Function: to-vector ITEM &key DIMENSION

Returns a new vector object based created from the
function’s arguments. If dimension is supplied, it should be a positive integer defining the dimension of the returned vector. If the specified dimension is shorter than the given item, extra elements are truncated. If it is longer, the new vector will be padded with zero elements.

Package
Source

vector.lisp (file)

Methods
Method: to-vector (ITEM list) &key DIMENSION

Converts a list to a vector.

Method: to-vector (ITEM vector) &key DIMENSION

Returns a copy of the given vector.

Generic Function: transform TRANSFORMER OBJECT

Applies the transformer to the object, and returns the appropriate result of the transformation.

Package
Source

transform.lisp (file)

Methods
Method: transform TRANSFORMER (SPLINE b-spline)

Transforms a spline. The TRANSFORMER should accept a point, and will be called once for each control point of the spline. The new spline will share the B-SPLINE-KNOTS of the old spline object.

Method: transform (FUNCTION function) (VECTOR vector)

Applies a function to a vector and returns the result.

Method: transform TRANSFORMER (LIST list)

Applies the transformer to all objects in a list, returning the list of results, much like MAPCAR.

Generic Function: transpose MATRIX

Returns the non-destructive transpose of a matrix

Package
Source

matrix.lisp (file)

Methods
Method: transpose (MATRIX matrix)
Generic Function: vector= LHS RHS

Returns t iff the two vectors are equal. Effected by *equivalence-tolerance*.

Package
Source

vector.lisp (file)

Methods
Method: vector= (LHS list) (RHS list)
Method: vector= (LHS vector) (RHS vector)
Generic Function: w VECTOR

Returns the w component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Writer

(setf w) (generic function)

Methods
Method: w (VECTOR vector)
Generic Function: (setf w) VALUE VECTOR

Sets the w component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Reader

w (generic function)

Generic Function: x VECTOR

Returns the x component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Writer

(setf x) (generic function)

Methods
Method: x (VECTOR vector)
Method: x (VECTOR list)

Allows a list to be treated accessed in a limited way as a vector.

Generic Function: (setf x) VALUE VECTOR

Sets the x component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Reader

x (generic function)

Generic Function: y VECTOR

Returns the y component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Writer

(setf y) (generic function)

Methods
Method: y (VECTOR vector)
Method: y (VECTOR list)

Allows a list to be accessed, in a limited way, as a vector.

Generic Function: (setf y) VALUE VECTOR

Sets the y component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Reader

y (generic function)

Generic Function: z VECTOR

Returns the z component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Writer

(setf z) (generic function)

Methods
Method: z (VECTOR vector)
Method: z (VECTOR list)

Allows a list to be accessed, in a limited way, as a vector.

Generic Function: (setf z) VALUE VECTOR

Sets the z component from an appropriately sized vector.

Package
Source

vector.lisp (file)

Reader

z (generic function)

Generic Function: zerop ITEM

Returns T iff the given item is zero, to the tolerance used by EQUIVALENT

Package
Source

generics.lisp (file)

Methods
Method: zerop (MATRIX matrix)

Returns T iff all components in the matrix is EQUIVALENT to zero.

Source

matrix.lisp (file)

Method: zerop (VECTOR list)

Returns T if all components of the vector are zero.

Source

vector.lisp (file)

Method: zerop (VECTOR vector)

Returns T if all components of the vector are zero.

Source

vector.lisp (file)

Method: zerop (NUMBER number)

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.5 Conditions

Condition: dimension-error ()
Package
Source

conditions.lisp (file)

Direct superclasses

l-math-error (condition)

Direct subclasses

required-dimension-error (condition)

Direct methods
Direct slots
Slot: dim1
Initargs

:dim1

Initform

(quote nil)

Readers

dimension-error-dim1 (generic function)

Slot: dim2
Initargs

:dim2

Initform

(quote nil)

Readers

dimension-error-dim2 (generic function)

Condition: l-math-error ()
Package
Source

conditions.lisp (file)

Direct superclasses

error (condition)

Direct subclasses
Direct methods
Direct slots
Slot: format-control
Initargs

:format-control

Initform

(quote "a general mathematical error has occured.")

Readers

l-math-error-format-control (generic function)

Slot: format-arguments
Initargs

:format-arguments

Initform

(quote nil)

Readers

l-math-error-format-arguments (generic function)

Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.6 Classes

Class: b-spline ()

A non-uniform b-spline implementation. It has much
code to speed up the uniform quadratic and cubic cases, however. But
it supports arbitrary degree non-uniform b-splines in an arbtirary n-dimensional space.

There are a number of options when constructing a b-spline. The
simplest is when constructing a uniform b-spline, like so:

(make-instance ’lm:b-spline :degree 3 :points *list-of-points* :uniform t)

A non-uniform parameterisation that attempts to equalise the
distance travelled over parameter sections is chord length parameterisation: (make-instance ’lm:b-spline :degree 3 :points *list-of-points* :chord-length t)

Another non-uniform parameterisation (the prefered parametrisation)
is centripetal parametrisation, which preserves ratios of square
roots of distances between points of the control geometry:
(make-instance ’lm:b-spline :degree 3 :points *list-of-points* :centripetal t)

Knots may be specified with the :knots argument, and should be
constructed using lm:MAKE-KNOTS.

Package
Source

spline.lisp (file)

Direct superclasses

spline (class)

Direct methods
Direct slots
Slot: points

A list of points used defining the b-spline polygon.

Type

list

Initargs

:points

Readers

b-spline-points (generic function)

Writers

(setf b-spline-points) (generic function)

Slot: knots

A structure detailing the spline’s knots.

Type

(or null l-math:b-spline-knots)

Initargs

:knots

Readers

b-spline-knots (generic function)

Writers

(setf b-spline-knots) (generic function)

Slot: degree

The degree of the b-spline. This defaults to cubic.

Type

integer

Initargs

:degree

Initform

3

Readers

b-spline-degree (generic function)

Writers

(setf b-spline-degree) (generic function)

Class: b-spline-knots ()

Some docs. You will likely find it more convenient
to construct instance of this class using MAKE-KNOTS. Notice that B-SPLINE-BASIS requires a phantom knot on either end of the knot sequence. MAKE-KNOTS will automatically add those knots for you.

Package
Source

basis.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: knots

An ascending collection of knots, stored with repetition.

Type

(or null (simple-array double-float))

Initargs

:knots

Readers

knots (generic function)

Writers

(setf knots) (generic function)

Slot: multiplicity

The multiplicity of the above knots.

Type

(or null (simple-array fixnum))

Initargs

:multiplicity

Readers

multiplicity (generic function)

Writers

(setf multiplicity) (generic function)

Slot: knot-count

The number of knots, taking in to account multiplicity.

Type

fixnum

Initform

0

Readers

knot-count (generic function)

Slot: no-multiplicity

Indicates whether there is a multiplicity or not in the knots.

Readers

no-multiplicity-p (generic function)

Slot: uniform

A boolean indicating whether this is a uniform sequence of knots or not.

Readers

uniform-p (generic function)

Class: bezier-curve ()

A general bezier curve class, which can be of any
degree (unlike CUBIC-BEZIER-CURVE, which is always cubic). Note that this is a single curve, and not a piecewise spline. If you want a piecewise generalisation of this, use the B-SPLINE class.

Package
Source

spline.lisp (file)

Direct superclasses

spline (class)

Direct methods
Direct slots
Slot: degree

The degree of the curve. The default is to be cubic.

Type

integer

Readers

bezier-curve-degree (generic function)

Writers

(setf bezier-curve-degree) (generic function)

Slot: bernstein-polynomials

A cached list of berstein-polynomials, used in the calculation of the curve.

Type

list

Readers

bernstein-polynomials (generic function)

Slot: spline-geometry

A list of points defining the
curve. For a cubic curve, that is 4 points. For a curve of degree n, there will be n+1 points.

Initargs

:spline-geometry

Class: catmull-rom-spline ()

The interpolating catmull-rom spline in 3-space. This spline passes through all of its control points. It is also called the Overhauser spine.

Package
Source

spline.lisp (file)

Direct superclasses

three-shared-spline (class)

Direct Default Initargs
InitargValue
:basis-matrix(l-math::make-catmull-rom-basis-matrix)
Class: cubic-bezier-curve ()

Represents a cubic bézier curve in 3-space.

Package
Source

spline.lisp (file)

Direct superclasses

last-shared-spline (class)

Direct Default Initargs
InitargValue
:basis-matrix(l-math::make-bezier-basis-matrix)
Class: hermite-curve ()

Represents a hermite curve in 3-space.

Package
Source

spline.lisp (file)

Direct superclasses

last-shared-spline (class)

Direct Default Initargs
InitargValue
:basis-matrix(l-math::make-hermite-basis-matrix)
Class: matrix ()

A mathematical matrix class.

Package
Source

matrix.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: data

A 2D array holding the matrix data.

Type

(array double-float)

Initargs

:data

Class: spline ()

A base class for all spline and parametric curve implementations.

Package
Source

spline.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Class: unrbs-spline ()

A uniform, non-rational b-spline in 3-space.

Package
Source

spline.lisp (file)

Direct superclasses

three-shared-spline (class)

Direct Default Initargs
InitargValue
:basis-matrix(l-math::make-uniform-nonrational-bspline-basis-matrix)
Class: vector ()

A mathematical vector class.

Package
Source

vector.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: data

An array holding the vector’s data

Type

(array double-float)

Initargs

:data

Previous: , Up: Definitions   [Contents][Index]

### 5.2 Internal definitions

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.1 Special variables

Special Variable: *perlin-gradients*

Stores the wavelet coefficients / gradients.

Package
Source

random.lisp (file)

Special Variable: *perlin-permutations*

A list of random permutations.

Package
Source

random.lisp (file)

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.2 Macros

Macro: create-list-operation-method NAME FUNCTION

Generates a method, such as c+, which operates on common lisp lists, treating them as if they were vectors.

Package
Source

operations.lisp (file)

Macro: create-vector-operation-method NAME FUNCTION

Expands into code that can be used to fill out one a method for one of the generic methods defined below, such as c+

Package
Source

operations.lisp (file)

Macro: etest-dimensions LHS RHS
Package
Source

tests.lisp (file)

Macro: etest-needed-vector-dimension VECTOR DIMENSION
Package
Source

tests.lisp (file)

Macro: fill-row MATRIX ITEM-NAME ROW-NUM

A macro useful for filling matrices in functions such as CREATE-ROTATION-MATRIX.

Package
Source

rotations.lisp (file)

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.3 Functions

Function: centripetal-parameterisation ALL-POINTS DEGREE

Produces a non-parameteric parameterisation for b-splines, where the ratio of parameters is equivalent to the square root of the ratio of the distances between the corresponding control points.

Package
Source

basis.lisp (file)

Function: chord-length-parameterisation ALL-POINTS DEGREE

Produces a non-parameteric parameterisation for b-splines, where the ratio of parameters is equivalent to the ratio of the distances between the corresponding control points.

Package
Source

basis.lisp (file)

Function: find-starting-knot-index KNOT-DATA DEGREE PARAMETER

Given knot data, the degree of a spline, and a parameter, this locates the first index of the knots which will be used to define the point on the given spline. Returns first the b-spline-basis family to be used, and then the offset index of the knot.

Package
Source

basis.lisp (file)

Function: make-bezier-basis-matrix ()

Returns the 4×4 Bézier basis matrix.

Package
Source

basis.lisp (file)

Function: make-catmull-rom-basis-matrix ()

Returns the 4×4 matrix for catmull-rom interpolating splines.

Package
Source

basis.lisp (file)

Function: make-hermite-basis-matrix ()

Returns the 4×4 hermite basis matrix.

Package
Source

basis.lisp (file)

Function: make-random-matrix ROWS COLS &key NOISE

Creates a MATRIX of the ROWS × COLS dimension filled with random values obtained by calling NOISE once for each element in the MATRIX. By default, this uses normally distributed random numbers with a mean of 0 and standard deviation of 1.

Package
Source

random.lisp (file)

Function: make-uniform-nonrational-bspline-basis-matrix ()

Returns a 4×4 matrix for the uniform, nonrational b-splines.

Package
Source

basis.lisp (file)

Function: number-needed-knots NUM-POINTS DEGREE

Given the number of points making up a spline, and the degree of the spline, this will tell us the number of required knots.

Package
Source

basis.lisp (file)

Function: private-bilinear-interpolation TOP-LEFT BOTTOM-LEFT TOP-RIGHT BOTTOM-RIGHT PARAMETER
Package
Source

interpolate.lisp (file)

Function: ratio-parameterisation ALL-POINTS DEGREE FUNCTION

This can be used to determine a knot sequence based on some ’distance’ between the given points. The distance is measured using FUNCTION, which should be a binary function returning a real. If this function is the euclidean distance metric, then this will produce chord-length parametrisation.

Package
Source

basis.lisp (file)

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.4 Generic functions

Generic Function: bernstein-polynomials OBJECT
Package
Methods
Method: bernstein-polynomials (BEZIER-CURVE bezier-curve)

A cached list of berstein-polynomials, used in the calculation of the curve.

Source

spline.lisp (file)

Generic Function: bezier-curve-degree OBJECT
Generic Function: (setf bezier-curve-degree) NEW-VALUE OBJECT
Package
Methods
Method: bezier-curve-degree (BEZIER-CURVE bezier-curve)
Method: (setf bezier-curve-degree) NEW-VALUE (BEZIER-CURVE bezier-curve)

The degree of the curve. The default is to be cubic.

Source

spline.lisp (file)

Method: (setf bezier-curve-degree) (DEGREE integer) (SPLINE bezier-curve) after
Source

spline.lisp (file)

Generic Function: calculate-knot-count KNOT-DATA

Returns the number of knots in the data, taking in to account multiplicity. Sets KNOT-COUNT accordingly.

Package
Source

basis.lisp (file)

Methods
Method: calculate-knot-count (KNOT-DATA b-spline-knots)
Generic Function: calculate-uniformity KNOT-DATA

Calculates whether the knot-data is uniform or not. Sets UNIFORM-P accordingly.

Package
Source

basis.lisp (file)

Methods
Method: calculate-uniformity (KNOT-DATA b-spline-knots)
Generic Function: dimension-error-dim1 CONDITION
Package
Methods
Method: dimension-error-dim1 (CONDITION required-dimension-error)
Source

conditions.lisp (file)

Method: dimension-error-dim1 (CONDITION dimension-error)
Source

conditions.lisp (file)

Generic Function: dimension-error-dim2 CONDITION
Package
Methods
Method: dimension-error-dim2 (CONDITION required-dimension-error)
Source

conditions.lisp (file)

Method: dimension-error-dim2 (CONDITION dimension-error)
Source

conditions.lisp (file)

Generic Function: get-ith-knot KNOT-DATA I &optional OFFSET

Returns the ith knot, taking in to account
multiplicity. OFFSET should be positive number that array indices are offset by.

Package
Source

basis.lisp (file)

Methods
Method: get-ith-knot (SPLINE b-spline) (I integer) &optional OFFSET
Source

spline.lisp (file)

Method: get-ith-knot (KNOT-DATA b-spline-knots) (I integer) &optional OFFSET
Generic Function: high-parameter KNOT-DATA DEGREE

Given a knot sequence and the degree of the spline,
this returns the highest possible parameter value the spline will aceept.

Package
Source

basis.lisp (file)

Methods
Method: high-parameter (KNOTS b-spline-knots) (DEGREE integer)
Generic Function: initialise-data ITEM SIZE

Initialises the DATA slot to the given size. Returns the vector object.

Package
Source

generics.lisp (file)

Methods
Method: initialise-data (MATRIX matrix) (SIZE-LIST list)
Source

matrix.lisp (file)

Method: initialise-data (VECTOR vector) (SIZE integer)
Source

vector.lisp (file)

Generic Function: knot-count OBJECT
Package
Methods
Method: knot-count (B-SPLINE-KNOTS b-spline-knots)

The number of knots, taking in to account multiplicity.

Source

basis.lisp (file)

Generic Function: l-math-error-format-arguments CONDITION
Package
Methods
Method: l-math-error-format-arguments (CONDITION l-math-error)
Source

conditions.lisp (file)

Generic Function: l-math-error-format-control CONDITION
Package
Methods
Method: l-math-error-format-control (CONDITION l-math-error)
Source

conditions.lisp (file)

Generic Function: low-parameter KNOT-DATA DEGREE

Given a knot sequence and the degree of the spline,
this returns the lowest possible parameter value the spline will accept.

Package
Source

basis.lisp (file)

Methods
Method: low-parameter (KNOTS b-spline-knots) (DEGREE integer)
Generic Function: no-multiplicity-p OBJECT
Package
Methods
Method: no-multiplicity-p (B-SPLINE-KNOTS b-spline-knots)

Indicates whether there is a multiplicity or not in the knots.

Source

basis.lisp (file)

Generic Function: operation-not-suported-operation-name CONDITION
Package
Methods
Method: operation-not-suported-operation-name (CONDITION operation-not-supported)
Source

conditions.lisp (file)

Generic Function: operation-not-supported-extra-information CONDITION
Package
Methods
Method: operation-not-supported-extra-information (CONDITION operation-not-supported)
Source

conditions.lisp (file)

Generic Function: test-nonzero VECTOR &optional THRESHOLD

Throws a ZERO-LENGTH-ERROR if the given vector has a length close to zero.

Package
Source

tests.lisp (file)

Methods
Method: test-nonzero VECTOR &optional THRESHOLD
Generic Function: uniform-p OBJECT
Package
Methods
Method: uniform-p (B-SPLINE-KNOTS b-spline-knots)

A boolean indicating whether this is a uniform sequence of knots or not.

Source

basis.lisp (file)

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.5 Conditions

Condition: operation-not-supported ()
Package
Source

conditions.lisp (file)

Direct superclasses

l-math-error (condition)

Direct methods
Direct slots
Slot: operation-name
Initargs

:operation-name

Initform

(quote "<generic operation>")

Readers

operation-not-suported-operation-name (generic function)

Slot: extra-information
Initargs

:extra-information

Initform

(quote nil)

Readers

operation-not-supported-extra-information (generic function)

Condition: required-dimension-error ()
Package
Source

conditions.lisp (file)

Direct superclasses

dimension-error (condition)

Direct methods
Direct slots
Slot: dim1
Initargs

:dim1

Initform

(quote nil)

Readers

dimension-error-dim1 (generic function)

Slot: dim2
Initargs

:dim2

Initform

(quote nil)

Readers

dimension-error-dim2 (generic function)

Condition: spline-geometry-error ()
Package
Source

conditions.lisp (file)

Direct superclasses

l-math-error (condition)

Direct slots
Slot: format-control
Initargs

:format-control

Initform

(quote "the geometry data for the spline is malformed.")

Condition: zero-norm-error ()
Package
Source

conditions.lisp (file)

Direct superclasses

l-math-error (condition)

Direct slots
Slot: format-control
Initargs

:format-control

Initform

(quote "the given vector is of zero length.")

Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.6 Classes

Class: last-shared-spline ()

This class is for those curves / splines who set up
their geometry matrices by repeating the last element in a set of four, such as the hermite and bézier curves.

Package
Source

spline.lisp (file)

Direct superclasses

matrix-spline (class)

Direct subclasses
Direct methods
Class: matrix-spline ()

Used to represent splines that are defined by basis matrices.

Package
Source

spline.lisp (file)

Direct superclasses

spline (class)

Direct subclasses
Direct methods
Direct slots
Slot: basis-matrix

Defines the behaviour of the
spline. For possible bases to use, see MAKE-HERMITE-BASIS-MATRIX, MAKE-BEZIER-BASIS-MATRIX, and MAKE-UNIFORM-NONRATIONAL-BSPLINE-BASIS-MATRIX

Initargs

:basis-matrix

Readers

basis-matrix (generic function)

Writers

(setf basis-matrix) (generic function)

Slot: geometry

An array storing the various geometry matrices that make up the spline.

Type

(or null simple-array)

Class: three-shared-spline ()

Represents those splines for which the last three
geometry points are always shared with a new point to construct the spline. These are splines such as the b-splines and catmull-rom splines.

Package
Source

spline.lisp (file)

Direct superclasses

matrix-spline (class)

Direct subclasses
Direct methods

Previous: , Up: Top   [Contents][Index]

## Appendix A Indexes

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.1 Concepts

Jump to: F   L
Jump to: F   L

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.2 Functions

Jump to: (   *   +   -   /   A   B   C   D   E   F   G   H   I   K   L   M   N   O   P   R   S   T   U   V   W   X   Y   Z
Jump to: (   *   +   -   /   A   B   C   D   E   F   G   H   I   K   L   M   N   O   P   R   S   T   U   V   W   X   Y   Z

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.3 Variables

Jump to: *   B   D   E   F   G   K   M   N   O   P   S   U
Jump to: *   B   D   E   F   G   K   M   N   O   P   S   U

Previous: , Up: Indexes   [Contents][Index]

### A.4 Data types

Jump to: B   C   D   H   L   M   O   P   R   S   T   U   V   Z
Jump to: B   C   D   H   L   M   O   P   R   S   T   U   V   Z