Source code for kittycad.models.path_segment

from typing import Literal, Optional, Union

from pydantic import BaseModel, Field, RootModel
from typing_extensions import Annotated

from ..models.angle import Angle
from ..models.point2d import Point2d
from ..models.point3d import Point3d


[docs]class line(BaseModel): """A straight line segment. Goes from the current path "pen" to the given endpoint.""" end: Point3d relative: bool type: Literal["line"] = "line"
[docs]class arc(BaseModel): """A circular arc segment.""" angle_end: float angle_start: float center: Point2d end: Optional[Angle] = None radius: float relative: bool start: Optional[Angle] = None type: Literal["arc"] = "arc"
[docs]class bezier(BaseModel): """A cubic bezier curve segment. Start at the end of the current line, go through control point 1 and 2, then end at a given point.""" control1: Point3d control2: Point3d end: Point3d relative: bool type: Literal["bezier"] = "bezier"
[docs]class tangential_arc(BaseModel): """Adds a tangent arc from current pen position with the given radius and angle.""" offset: Angle radius: float type: Literal["tangential_arc"] = "tangential_arc"
[docs]class tangential_arc_to(BaseModel): """Adds a tangent arc from current pen position to the new position.""" angle_snap_increment: Optional[Angle] = None to: Point3d type: Literal["tangential_arc_to"] = "tangential_arc_to"
PathSegment = RootModel[ Annotated[ Union[ line, arc, bezier, tangential_arc, tangential_arc_to, ], Field(discriminator="type"), ] ]