Geometrical Points.
Point3D
A point in a 3-dimensional Euclidean space.
Parameters: | coords : sequence of 3 coordinate values. |
---|---|
Raises: | NotImplementedError :
TypeError :
|
Notes
Currently only 2-dimensional and 3-dimensional points are supported.
Examples
>>> from sympy import Point3D
>>> from sympy.abc import x
>>> Point3D(1, 2, 3)
Point3D(1, 2, 3)
>>> Point3D([1, 2, 3])
Point3D(1, 2, 3)
>>> Point3D(0, x, 3)
Point3D(0, x, 3)
Floats are automatically converted to Rational unless the evaluate flag is False:
>>> Point3D(0.5, 0.25, 2)
Point3D(1/2, 1/4, 2)
>>> Point3D(0.5, 0.25, 3, evaluate=False)
Point3D(0.5, 0.25, 3)
Attributes
x | |
y | |
z | |
length |
Is a sequence of points collinear?
Test whether or not a set of points are collinear. Returns True if the set of points are collinear, or False otherwise.
Parameters: | points : sequence of Point |
---|---|
Returns: | are_collinear : boolean |
See also
Examples
>>> from sympy import Point3D, Matrix
>>> from sympy.abc import x
>>> p1, p2 = Point3D(0, 0, 0), Point3D(1, 1, 1)
>>> p3, p4, p5 = Point3D(2, 2, 2), Point3D(x, x, x), Point3D(1, 2, 6)
>>> Point3D.are_collinear(p1, p2, p3, p4)
True
>>> Point3D.are_collinear(p1, p2, p3, p5)
False
This function tests whether passed points are coplanar or not. It uses the fact that the triple scalar product of three vectors vanishes if the vectors are coplanar. Which means that the volume of the solid described by them will have to be zero for coplanarity.
Parameters: | A set of points 3D points : |
---|---|
Returns: | boolean : |
Examples
>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 2)
>>> p2 = Point3D(2, 7, 2)
>>> p3 = Point3D(0, 0, 2)
>>> p4 = Point3D(1, 1, 2)
>>> Point3D.are_coplanar(p1, p2, p3, p4)
True
>>> p5 = Point3D(0, 1, 3)
>>> Point3D.are_coplanar(p1, p2, p3, p5)
False
Gives the direction cosine between 2 points
Parameters: | p : Point3D |
---|---|
Returns: | list : |
Examples
>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 3)
>>> p1.direction_cosine(Point3D(2, 3, 5))
[sqrt(6)/6, sqrt(6)/6, sqrt(6)/3]
Gives the direction ratio between 2 points
Parameters: | p : Point3D |
---|---|
Returns: | list : |
Examples
>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 3)
>>> p1.direction_ratio(Point3D(2, 3, 5))
[1, 1, 2]
The Euclidean distance from self to point p.
Parameters: | p : Point |
---|---|
Returns: | distance : number or symbolic expression. |
See also
Examples
>>> from sympy import Point3D
>>> p1, p2 = Point3D(1, 1, 1), Point3D(4, 5, 0)
>>> p1.distance(p2)
sqrt(26)
>>> from sympy.abc import x, y, z
>>> p3 = Point3D(x, y, z)
>>> p3.distance(Point3D(0, 0, 0))
sqrt(x**2 + y**2 + z**2)
Evaluate the coordinates of the point.
This method will, where possible, create and return a new Point where the coordinates are evaluated as floating point numbers to the precision indicated (default=15).
Returns: | point : Point |
---|
Examples
>>> from sympy import Point3D, Rational
>>> p1 = Point3D(Rational(1, 2), Rational(3, 2), Rational(5, 2))
>>> p1
Point3D(1/2, 3/2, 5/2)
>>> p1.evalf()
Point3D(0.5, 1.5, 2.5)
The intersection between this point and another point.
Parameters: | other : Point |
---|---|
Returns: | intersection : list of Points |
Notes
The return value will either be an empty list if there is no intersection, otherwise it will contain this point.
Examples
>>> from sympy import Point3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 0, 0)
>>> p1.intersection(p2)
[]
>>> p1.intersection(p3)
[Point3D(0, 0, 0)]
Treating a Point as a Line, this returns 0 for the length of a Point.
Examples
>>> from sympy import Point3D
>>> p = Point3D(0, 1, 1)
>>> p.length
0
The midpoint between self and point p.
Parameters: | p : Point |
---|---|
Returns: | midpoint : Point |
See also
Examples
>>> from sympy import Point3D
>>> p1, p2 = Point3D(1, 1, 1), Point3D(13, 5, 1)
>>> p1.midpoint(p2)
Point3D(7, 3, 1)
Evaluate the coordinates of the point.
This method will, where possible, create and return a new Point where the coordinates are evaluated as floating point numbers to the precision indicated (default=15).
Returns: | point : Point |
---|
Examples
>>> from sympy import Point3D, Rational
>>> p1 = Point3D(Rational(1, 2), Rational(3, 2), Rational(5, 2))
>>> p1
Point3D(1/2, 3/2, 5/2)
>>> p1.evalf()
Point3D(0.5, 1.5, 2.5)
Scale the coordinates of the Point by multiplying by x and y after subtracting pt – default is (0, 0) – and then adding pt back again (i.e. pt is the point of reference for the scaling).
See also
Examples
>>> from sympy import Point3D
>>> t = Point3D(1, 1, 1)
>>> t.scale(2)
Point3D(2, 1, 1)
>>> t.scale(2, 2)
Point3D(2, 2, 1)
Return the point after applying the transformation described by the 3x3 Matrix, matrix.
See also
geometry.entity.rotate, geometry.entity.scale, geometry.entity.translate
Shift the Point by adding x and y to the coordinates of the Point.
See also
rotate, scale
Examples
>>> from sympy import Point3D
>>> t = Point3D(0, 1, 1)
>>> t.translate(2)
Point3D(2, 1, 1)
>>> t.translate(2, 2)
Point3D(2, 3, 1)
>>> t + Point3D(2, 2, 2)
Point3D(2, 3, 3)
Returns the X coordinate of the Point.
Examples
>>> from sympy import Point3D
>>> p = Point3D(0, 1, 3)
>>> p.x
0