from partpoint import Point2D, Vector2D # create a point at (2, 3) in 2D space p = Point2D(2, 3) # create a vector pointing from (1, 1) to (3, 4) in 2D space v = Vector2D.from_points(Point2D(1, 1), Point2D(3, 4)) # calculate the distance between two points dist = Point2D.distance_between(p, Point2D(5, 6)) # calculate the dot product of two vectors dot_product = Vector2D.dot_product(Vector2D(1, 2), Vector2D(3, 4))
from partpoint import Point3D, Vector3D # create a point at (1, 2, 3) in 3D space p = Point3D(1, 2, 3) # create a vector pointing from (1, 3, 2) to (4, 1, 5) in 3D space v = Vector3D.from_points(Point3D(1, 3, 2), Point3D(4, 1, 5)) # calculate the cross product of two vectors cross_product = Vector3D.cross_product(Vector3D(1, 2, 1), Vector3D(3, 4, 3))
from partpoint import Line2D, Segment2D, Polygon2D # create a line passing through (1, 1) and (3, 4) in 2D space line = Line2D.from_points(Point2D(1, 1), Point2D(3, 4)) # create a segment connecting (1, 1) and (3, 4) in 2D space segment = Segment2D.from_points(Point2D(1, 1), Point2D(3, 4)) # create a polygon with vertices (1, 1), (2, 3), and (4, 1) in 2D space polygon = Polygon2D([Point2D(1, 1), Point2D(2, 3), Point2D(4, 1)]) # calculate the length of a line length = line.length() # calculate the area of a polygon area = polygon.area()