Core Help Root: Objects: Math Library
Vector operations
- .add(v1,v2) native
- Vector addition. It adds two floating-point lists, element-by-element.
- .sub(v1,v2) native
- Vector substraction.
- .dot(v1,v2) native
- Dot product of two vectors.
- .cross(v1,v2) native
- Cross product of 3-dimensional vectors.
- .distance(v1,v2) native
- Euclidean distance between the two vectors.
- .scale(x,v) native
- Scales the vector v by scalar x.
- .minor(v1,v2) native
- Calculates element-by-element minimum of the two lists. Used for boxes.
- .major(v1,v2) native
- Calculates element-by-element maximum.
- .is_lower(v1,v2) native
- Returns true if every element of v1 is lesser or equal than corresponding element of v2.
Coordinate operations
- .pi()
- Returns pi.
- .pi2()
- Returns 2*pi.
- .deg_rad(angle)
- Converts the angle from degrees to radians.
- .rad_deg(angle)
- Converts the angle from radians to degrees.
- .polar_rectangular(coords)
- Transforms pair [distance, angle] into [x,y].
- .rectangular_polar(coords)
- Inverse of the above.
- .cylindrical_rectangular(coords)
- Transforms [r, angle, z] into [x,y,z].
- .rectangular_cylindrical(coords)
- Inverse of the above.
- .spherical_rectangular(coords)
- Transform [r, phi, theta] into [x,y,z].
- .rectangular_spherical(coords)
- Inverse of the above.
Matrix operations
- .matrix_add(m1,m2)
- Add two matrices.
- .matrix_sub(m1,m2)
- Substract m2 from m1
- .matrix_mul(m1,m2)
- Multiply the two matrices (their dimensions must be compatible for multiplication, of course)
- .matrix_scale(s,m)
- Scale the matrix m by scalar s.
- .transpose(m)
- Transpose the matrix. This will actually work regardless of the element type, so the operation is useful on lists, as well.
- .ident_mat(n)
- Returns n-dimensional identity matrix.
- .translation_mat(v)
- Constructs the matrix for translation by vector v. It works for 2d or 3d case.
- .tensor(m1,m2)
- Tensor product of the two vectors. This is the matrix A with the property that Ax=<x,v1>v2.
- .skew(v)
- Construct a skew operator for the vector v. That's matrix A that turns any vector into its cross product with v. This is used by rotation_mat_3d.
- .rotation_mat_2d(angle)
- Construct 2d rotation matrix for the given angle.
- .rotation_mat_3d(axis,angle)
- This is 3d rotation. Valid values for axis are 'x, 'y, 'z, or a 3d vector. The result is a homogenous matrix.
- .scale_mat(scale)
- Returns a scaling matrix (nonuniform). Scale is assumed to be 2d or 3d vector.
- .transform_vect(m,v)
- Transform the vector by matrix. This will work for both normal and homogenous matrices (determined by comparing the dimensions of the matrix and vector).
Miscellanous
- .runge(x,y,h,f,data)
- This is one step in Runge-Kutta method for ordinary differential equations. Scalar x and vector y are the current values of independant and dependant variables, h is the timestep, f is the method on the sender that accepts x, y, and data, and returns the right-hand-side of the equation.
the Cold Dark