Below is a detailed description of all available Classes and functions.
A Point represents a single Point in 3D space. You can create a point by giving either three coordinates as parameters, or a list with three elements, each being a coordinate, or by giving a Vector.
Returns the origin, that is the Point with coordinates (0, 0, 0)
Returns the nth coordinate of the point:
Point(x1, x2, x3)
n: 0 1 2
>>> p = Point(13, 3, 7)
>>> p[0]
13
>>> p[1]
3
>>> p[2]
7
Returns the position vector of the point, this is a Vector that has the same coordinates as the point:
>>> p = Point(13, 3, 7)
>>> p.pv()
Vector(13, 3, 7)
Returns the point that you get when you move self by vector:
>>> p = Point(13, 3, 7)
>>> v = Vector(29, 1, -5)
>>> p.moved(v)
Point(42, 4, 2)
>>> # Equivalent to
... Point(p.pv() + v)
Point(42, 4, 2)
The Vector class represents a vector in 3D space. You can construct a vector either by giving the three coordinates directly (1st form), by giving an iterable that yields the three coordinates (like a list) (2nd form) or by giving two Points. The vector will then go from the first point to the second (3rd form).
Vectors support the following calculations: (a and b are vectors, c is a real number)
Operation | Result |
---|---|
a + b | Sum vector |
a - b | Difference vector |
c * a | Multiple of a vector |
a * b | Dot product/inner product/ scalar product |
abs(a) | Magnitude/length of a vector |
-a | Reverse vector (same magnitude, reversed direction) |
a[n] | nth coordiante of the vector |
Returns Vector(0, 0, 0)
Return the angle (in radians) between two vectors:
>>> a = Vector(3, 0, 0)
>>> b = Vector(42, 0, 0)
>>> a.angle(b)
0.0
Return the cross product between two vectors, as defined by
Returns the length (or magnitude) of the vector, a.length() = abs(a)
Returns the normalized version of the vector, that is a vector that has the same direction but length 1:
>>> v = Vector(0, 3, 0)
>>> v = v.normalized()
>>> v
Vector(0, 1, 0)
>>> abs(v)
1.0
Returns True if the two vectors are orthogonal to each other:
>>> a = Vector(3, 0, 0)
>>> b = Vector(0, 1, 1)
>>> a.orthogonal(b)
True
Returns True if the two vectors are parallel to each other.
The Line class represents an infinitely long line in 3D space. You can specify a Line by two Points (1st form), in this case the resulting Line will be the one going through both Points.
Otherwise you can specify a Line by giving a single Point on the Line and a Vector showing the direction of the Line (2nd form). Instead of the Point itself you can also give the position vector of the Point (3rd form).
Operation | Result |
---|---|
a in b | Returns True if Point a lies on the Line b |
a == b | Returns True if Lines a and b are the same, even though they might have different representations |
Returns a tuple of two vectors needed to describe the Line. Let (s, d) be the return value of the function, then the Line can be expressed as
The Plane class represents a plane in 3D space (not the flying plane).
In the 1st form a Plane is initialised by giving 3 points that are part of the plane.
In the 2nd form a Plane is initialised by giving an arbitrary point on the plane and two vectors lying on the Plane (they must not be parallel).
In the 3rd form a Plane is initialised by giving an arbitrary point on the plane and the normal vector of the plane, that is the vector that is orthogonal to the plane.
In the 4th form a Plane is initialised by giving the four coefficients of
the general form
Operation | Result |
---|---|
a in b | Returns True if Point or Line a lies on the Plane b |
a == b | Returns True if Planes a and b are the same, even though they might have different representations |
Returns (a, b, c, d), the coefficients for the general form
Returns vectors (s, u, v) for the parametric form
Returns vectors (p, n) for the point-normal form
The following functions work for any combination of Line and Plane.
Returns the angle (in radians) between a and b.
Returns the distance between a and b.
Note
This function also works with Point.
Returns the intersection of a and b. Depending on the Type of the intersection, this can return
Returns True if a and b are orthogonal
Returns True if a and b are parallel
If you have vtk installed, you can use the draw() function to get a visual representation of your lines and planes.
Open an interactive window with a visual representation of the given list of elements. Currently supported are
Parameters: |
|
---|
See Examples for an example on how to use the draw function.