3D Point¶

Geometrical Points.

Contains¶

Point3D

class sympy.geometry.point3d.Point3D[source]

A point in a 3-dimensional Euclidean space.

Parameters : coords : sequence of 3 coordinate values. NotImplementedError : When trying to create a point other than 2 or 3 dimensions. When $$intersection$$ is called with object other than a Point. TypeError : When trying to add or subtract points with different dimensions.

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
static are_collinear(*points)[source]

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 are_collinear : boolean

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

static are_coplanar(*points)[source]

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 : 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

direction_cosine(point)[source]

Gives the direction cosine between 2 points

Parameters : p : Point3D 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]

direction_ratio(point)[source]

Gives the direction ratio between 2 points

Parameters : p : Point3D list :

Examples

>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 3)
>>> p1.direction_ratio(Point3D(2, 3, 5))
[1, 1, 2]

distance(p)[source]

The Euclidean distance from self to point p.

Parameters : p : Point distance : number or symbolic expression.

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)

dot(p2)[source]

Return dot product of self with another Point.

evalf(prec=None, **options)[source]

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)

intersection(o)[source]

The intersection between this point and another point.

Parameters : other : Point 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)]

length[source]

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

midpoint(p)[source]

The midpoint between self and point p.

Parameters : p : Point midpoint : Point

Examples

>>> from sympy import Point3D
>>> p1, p2 = Point3D(1, 1, 1), Point3D(13, 5, 1)
>>> p1.midpoint(p2)
Point3D(7, 3, 1)

n(prec=None, **options)

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(x=1, y=1, z=1, pt=None)[source]

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).

translate

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)

transform(matrix)[source]

Return the point after applying the transformation described by the 3x3 Matrix, matrix.

geometry.entity.rotate, geometry.entity.scale, geometry.entity.translate

translate(x=0, y=0, z=0)[source]

Shift the Point by adding x and y to the coordinates of the Point.

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)

x[source]

Returns the X coordinate of the Point.

Examples

>>> from sympy import Point3D
>>> p = Point3D(0, 1, 3)
>>> p.x
0

y[source]

Returns the Y coordinate of the Point.

Examples

>>> from sympy import Point3D
>>> p = Point3D(0, 1, 2)
>>> p.y
1

z[source]

Returns the Z coordinate of the Point.

Examples

>>> from sympy import Point3D
>>> p = Point3D(0, 1, 1)
>>> p.z
1