Geometry3D package

Subpackages

Module contents

class Geometry3D.ConvexPolyhedron(convex_polygons)[source]

Bases: Geometry3D.geometry.body.GeoBody

classmethod Cone(circle_center, radius, height_vector, n=10)[source]

A special function for creating the inscribed polyhedron of a sphere

Input:

  • circle_center: The center of the bottom circle

  • radius: The radius of the bottom circle

  • height_vector: The Vector from the bottom circle center to the top circle center

  • n=10: The number of Points on the bottom circle

Output:

  • An inscribed polyhedron of the given cone.

classmethod Cylinder(circle_center, radius, height_vector, n=10)[source]

A special function for creating the inscribed polyhedron of a sphere

Input:

  • circle_center: The center of the bottom circle

  • radius: The radius of the bottom circle

  • height_vector: The Vector from the bottom circle center to the top circle center

  • n=10: The number of Points on the bottom circle

Output:

  • An inscribed polyhedron of the given cylinder.

classmethod Parallelepiped(base_point, v1, v2, v3)[source]

A special function for creating Parallelepiped

Input:

  • base_point: a Point

  • v1, v2, v3: three Vectors

Output:

  • A parallelepiped which is a ConvexPolyhedron instance.

classmethod Sphere(center, radius, n1=10, n2=3)[source]

A special function for creating the inscribed polyhedron of a sphere

Input:

  • center: The center of the sphere

  • radius: The radius of the sphere

  • n1=10: The number of Points on a longitude circle

  • n2=3: The number sections of a quater latitude circle

Output:

  • An inscribed polyhedron of the given sphere.

area()[source]

return the total area of the polyhedron

class_level = 5

Input:

  • convex_polygons: tuple of ConvexPolygons

Output:

  • ConvexPolyhedron

  • The correctness of convex_polygons are checked According to Euler’s formula.

  • The normal of the convex polygons are checked and corrected which should be toward the outer direction

length()[source]

return the total length of the polyhedron

move(v)[source]

Return the ConvexPolyhedron that you get when you move self by vector v, self is also moved

volume()[source]

return the total volume of the polyhedron

Geometry3D.Parallelepiped(base_point, v1, v2, v3)

A special function for creating Parallelepiped

Input:

  • base_point: a Point

  • v1, v2, v3: three Vectors

Output:

  • A parallelepiped which is a ConvexPolyhedron instance.

Geometry3D.Sphere(center, radius, n1=10, n2=3)

A special function for creating the inscribed polyhedron of a sphere

Input:

  • center: The center of the sphere

  • radius: The radius of the sphere

  • n1=10: The number of Points on a longitude circle

  • n2=3: The number sections of a quater latitude circle

Output:

  • An inscribed polyhedron of the given sphere.

Geometry3D.Cone(circle_center, radius, height_vector, n=10)

A special function for creating the inscribed polyhedron of a sphere

Input:

  • circle_center: The center of the bottom circle

  • radius: The radius of the bottom circle

  • height_vector: The Vector from the bottom circle center to the top circle center

  • n=10: The number of Points on the bottom circle

Output:

  • An inscribed polyhedron of the given cone.

Geometry3D.Cylinder(circle_center, radius, height_vector, n=10)

A special function for creating the inscribed polyhedron of a sphere

Input:

  • circle_center: The center of the bottom circle

  • radius: The radius of the bottom circle

  • height_vector: The Vector from the bottom circle center to the top circle center

  • n=10: The number of Points on the bottom circle

Output:

  • An inscribed polyhedron of the given cylinder.

class Geometry3D.ConvexPolygon(pts, reverse=False, check_convex=False)[source]

Bases: Geometry3D.geometry.body.GeoBody

  • ConvexPolygons(points)

points: a tuple of points.

The points needn’t to be in order.

The convexity should be guaranteed. This function will not check the convexity. If the Polygon is not convex, there might be errors.

classmethod Circle(center, normal, radius, n=10)[source]

A special function for creating an inscribed convex polygon of a circle

Input:

  • Center: The center point of the circle

  • normal: The normal vector of the circle

  • radius: The radius of the circle

  • n=10: The number of Points of the ConvexPolygon

Output:

  • An inscribed convex polygon of a circle.

classmethod Parallelogram(base_point, v1, v2)[source]

A special function for creating Parallelogram

Input:

  • base_point: a Point

  • v1, v2: two Vectors

Output:

  • A parallelogram which is a ConvexPolygon instance.

area()[source]

Input:

  • self

Output:

  • The area of the convex polygon

class_level = 4
eq_with_normal(other)[source]

return whether self equals with other considering the normal

hash_with_normal()[source]

return the hash value considering the normal

in_(other)[source]

Input:

  • self: ConvexPolygon

  • other: Plane

Output:

  • whether self in other

length()[source]

return the total length of ConvexPolygon

move(v)[source]

Return the ConvexPolygon that you get when you move self by vector v, self is also moved

segments()[source]

Input:

  • self

Output:

  • iterator of segments

Geometry3D.Parallelogram(base_point, v1, v2)

A special function for creating Parallelogram

Input:

  • base_point: a Point

  • v1, v2: two Vectors

Output:

  • A parallelogram which is a ConvexPolygon instance.

Geometry3D.Circle(center, normal, radius, n=10)

A special function for creating an inscribed convex polygon of a circle

Input:

  • Center: The center point of the circle

  • normal: The normal vector of the circle

  • radius: The radius of the circle

  • n=10: The number of Points of the ConvexPolygon

Output:

  • An inscribed convex polygon of a circle.

class Geometry3D.Pyramid(cp, p, direct_call=True)[source]

Bases: Geometry3D.geometry.body.GeoBody

Input:

  • cp: a ConvexPolygon

  • p: a Point

height()[source]

return the height of the pyramid

volume()[source]

return the volume of the pryamid

class Geometry3D.Segment(a, b)[source]

Bases: Geometry3D.geometry.body.GeoBody

Input:

  • Segment(Point,Point)

  • Segment(Point,Vector)

class_level = 3
in_(other)[source]

other can be plane or line

length()[source]

retutn the length of the segment

move(v)[source]

Return the Segment that you get when you move self by vector v, self is also moved

parametric()[source]

Returns (start_point, end_point) so that you can build the information for the segment

class Geometry3D.Line(a, b)[source]

Bases: Geometry3D.geometry.body.GeoBody

  • Line(Point, Point):

A Line going through both given points.

  • Line(Point, Vector):

A Line going through the given point, in the direction pointed by the given Vector.

  • Line(Vector, Vector):

The same as Line(Point, Vector), but with instead of the point only the position vector of the point is given.

class_level = 1
move(v)[source]

Return the line that you get when you move self by vector v, self is also moved

parametric()[source]
Returns (s, u) so that you can build the equation for the line

_ _ _

g: x = s + ru ; r e R

classmethod x_axis()[source]

return x axis which is a Line

classmethod y_axis()[source]

return y axis which is a Line

classmethod z_axis()[source]

return z axis which is a Line

class Geometry3D.Plane(*args)[source]

Bases: Geometry3D.geometry.body.GeoBody

  • Plane(Point, Point, Point):

Initialise a plane going through the three given points.

  • Plane(Point, Vector, Vector):

Initialise a plane given by a point and two vectors lying on the plane.

  • Plane(Point, Vector):

Initialise a plane given by a point and a normal vector (point normal form)

  • Plane(a, b, c, d):

Initialise a plane given by the equation ax1 + bx2 + cx3 = d (general form).

class_level = 2
general_form()[source]

Returns (a, b, c, d) so that you can build the equation

E: ax1 + bx2 + cx3 = d

to describe the plane.

move(v)[source]

Return the plane that you get when you move self by vector v, self is also moved

parametric()[source]
Returns (u, v, w) so that you can build the equation

_ _ _ _

E: x = u + rv + sw ; (r, s) e R

to describe the plane (a point and two vectors).

point_normal()[source]
Returns (p, n) so that you can build the equation

_ _

E: (x - p) n = 0

to describe the plane.

classmethod xy_plane()[source]

return xy plane which is a Plane

classmethod xz_plane()[source]

return xz plane which is a Plane

classmethod yz_plane()[source]

return yz plane which is a Plane

class Geometry3D.Point(*args)[source]

Bases: object

  • Point(a, b, c)

  • Point([a, b, c]):

The point with coordinates (a | b | c)

  • Point(Vector):

The point that you get when you move the origin by the given vector. If the vector has coordinates (a | b | c), the point will have the coordinates (a | b | c) (as easy as pi).

class_level = 0
distance(other)[source]

Return the distance between self and other

move(v)[source]

Return the point that you get when you move self by vector v, self is also moved

classmethod origin()[source]

Returns the Point (0 | 0 | 0)

pv()[source]

Return the position vector of the point.

class Geometry3D.HalfLine(a, b)[source]

Bases: Geometry3D.geometry.body.GeoBody

Input:

  • HalfLine(Point,Point)

  • HalfLine(Point,Vector)

class_level = 6
in_(other)[source]

other can be plane or line

move(v)[source]

Return the HalfLine that you get when you move self by vector v, self is also moved

parametric()[source]

Returns (point, vector) so that you can build the information for the halfline

class Geometry3D.Vector(*args)[source]

Bases: object

Vector Class

angle(other)[source]

Returns the angle (in radians) enclosed by both vectors.

cross(other)[source]

Calculates the cross product of two vectors, defined as _ _ / x2y3 - x3y2 x × y = | x3y1 - x1y3 |

x1y2 - x2y1 /

The cross product is orthogonal to both vectors and its length is the area of the parallelogram given by x and y.

length()[source]

Returns |v|, the length of the vector.

normalized()[source]

Return the normalized version of the vector, that is a vector pointing in the same direction but with length 1.

orthogonal(other)[source]

Returns true if the two vectors are orthogonal

parallel(other)[source]

Returns true if both vectors are parallel.

unit()

Return the normalized version of the vector, that is a vector pointing in the same direction but with length 1.

classmethod x_unit_vector()[source]

Returns the unit vector (1 | 0 | 0)

classmethod y_unit_vector()[source]

Returns the unit vector (0 | 1 | 0)

classmethod z_unit_vector()[source]

Returns the unit vector (0 | 0 | 1)

classmethod zero()[source]

Returns the zero vector (0 | 0 | 0)

Geometry3D.angle(a, b)[source]

Input:

  • a: Line/Plane/Plane/Vector

  • b: Line/Line/Plane/Vector

Output:

The angle (in radians) between

  • Line/Line

  • Plane/Line

  • Plane/Plane

  • Vector/Vector

Geometry3D.distance(a, b)[source]

Input:

  • a: Point/Line/Line/Plane/Plane

  • b: Point/Point/Line/Point/Line

Output:

Returns the distance between two objects. This includes

  • Point/Point

  • Line/Point

  • Line/Line

  • Plane/Point

  • Plane/Line

Geometry3D.intersection(a, b)[source]

Input:

  • a: GeoBody or None

  • b: GeoBody or None

Output:

The Intersection.

Maybe None or GeoBody

Geometry3D.orthogonal(a, b)[source]

Input:

  • a:Line/Plane/Plane/Vector

  • b:Line/Line/Plane/Vector

Output:

A boolean of whether the two objects are orthogonal. This can check

  • Line/Line

  • Plane/Line

  • Plane/Plane

  • Vector/Vector

Geometry3D.parallel(a, b)[source]

Input:

  • a:Line/Plane/Plane/Vector

  • b:Line/Line/Plane/Vector

Output:

A boolean of whether the two objects are parallel. This can check

  • Line/Line

  • Plane/Line

  • Plane/Plane

  • Vector/Vector

Geometry3D.solve(matrix)[source]
Geometry3D.volume(arg)[source]

Input:

  • arg: Pyramid or ConvexPolyhedron

Output:

Returns the object volume. This includes

  • Pyramid

  • ConvexPolyhedron

Geometry3D.Renderer(backend='matplotlib')[source]

Input:

  • backend: the backend of the renderer

Only matplotlib is supported till now

Geometry3D.origin()

Returns the Point (0 | 0 | 0)

Geometry3D.x_axis()

return x axis which is a Line

Geometry3D.y_axis()

return y axis which is a Line

Geometry3D.z_axis()

return z axis which is a Line

Geometry3D.x_unit_vector()

Returns the unit vector (1 | 0 | 0)

Geometry3D.y_unit_vector()

Returns the unit vector (0 | 1 | 0)

Geometry3D.z_unit_vector()

Returns the unit vector (0 | 0 | 1)

Geometry3D.xy_plane()

return xy plane which is a Plane

Geometry3D.yz_plane()

return yz plane which is a Plane

Geometry3D.xz_plane()

return xz plane which is a Plane

Geometry3D.set_eps(eps=1e-10)[source]

Input:

  • eps: floating number with 1e-10 the default

Output:

No output but set EPS to eps

Signigicant numbers is also changed.

Geometry3D.get_eps()[source]

Input:

no input

Output:

  • current eps: float

Geometry3D.get_sig_figures()[source]

Input:

no input

Output:

  • current significant numbers: int

Geometry3D.set_sig_figures(sig_figures=10)[source]

Input:

  • sig_figures: int with 10 the default

Output:

No output but set signigicant numbers to sig_figures

EPS is also changed.

Geometry3D.get_main_logger()[source]

Input:

No Input

Output:

main_logger: The logger instance

Geometry3D.set_log_level(level='WARNING')[source]

Input:

  • level: a string of log level among ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’.

    ‘WARNING’ is the default.

Output:

No output but setup the log level for the logger

Geometry3D.get_projection_length(v1, v2)[source]

Input:

  • v1: Vector

  • v2: Vector

Output:

The length of vector that v1 projected on v2

Geometry3D.get_relative_projection_length(v1, v2)[source]

Input:

  • v1: Vector

  • v2: Vector

Output:

The ratio of length of vector that v1 projected on v2 and the length of v2

Geometry3D.get_segment_from_point_list(point_list)[source]

Input:

  • point_list: a list of Points

Output:

The longest segment between the points

Geometry3D.get_segment_convexpolyhedron_intersection_point_set(s, cph)[source]

Input:

  • s: Segment

  • cph: ConvexPolyhedron

Output:

A set of intersection points

Geometry3D.get_segment_convexpolygon_intersection_point_set(s, cpg)[source]

Input:

  • s: Segment

  • cpg: ConvexPolygon

Output:

A set of intersection points

Geometry3D.points_in_a_line(points)[source]

Input:

  • points: Tuple or list of Points

Output:

A set of intersection points

Geometry3D.get_circle_point_list(center, normal, radius, n=10)[source]