1.. _math utilities:
2
3.. module:: ezdxf.math
4
5Utility functions and classes located in module :mod:`ezdxf.math`.
6
7Functions
8=========
9
10.. autofunction:: closest_point
11
12.. autofunction:: uniform_knot_vector
13
14.. autofunction:: open_uniform_knot_vector
15
16.. autofunction:: required_knot_values
17
18.. autofunction:: xround
19
20.. autofunction:: linspace
21
22.. autofunction:: area
23
24.. autofunction:: arc_angle_span_deg
25
26.. autofunction:: ellipse_param_span
27
28.. _bulge_related_functions:
29
30Bulge Related Functions
31-----------------------
32
33.. seealso::
34
35    Description of the :ref:`bulge value`.
36
37.. autofunction:: bulge_center
38
39.. autofunction:: bulge_radius
40
41.. autofunction:: arc_to_bulge
42
43.. autofunction:: bulge_to_arc
44
45.. autofunction:: bulge_3_points
46
472D Functions
48============
49
50.. autofunction:: arc_segment_count
51
52.. autofunction:: arc_chord_length
53
54.. autofunction:: distance_point_line_2d(point: Vec2, start: Vec2, end: Vec2) -> float
55
56.. autofunction:: point_to_line_relation(point: Vec2, start: Vec2, end: Vec2, abs_tol=1e-10) -> int
57
58.. autofunction:: is_point_on_line_2d(point: Vec2, start: Vec2, end: Vec2, ray=True, abs_tol=1e-10) -> bool
59
60.. autofunction:: is_point_left_of_line(point: Vec2, start: Vec2, end: Vec2, colinear=False) -> bool
61
62.. autofunction:: is_point_in_polygon_2d(point: Vec2, polygon: Iterable[Vec2], abs_tol=1e-10) -> int
63
64.. autofunction:: convex_hull_2d
65
66.. autofunction:: intersection_line_line_2d(line1: Sequence[Vec2], line2: Sequence[Vec2], virtual=True, abs_tol=1e-10) -> Optional[Vec2]
67
68.. autofunction:: rytz_axis_construction(d1: Vec3, d2: Vec3) -> Tuple[Vec3, Vec3, float]
69
70.. autofunction:: clip_polygon_2d
71
72.. autofunction:: offset_vertices_2d
73
74.. code-block:: Python
75
76    source = [(0, 0), (3, 0), (3, 3), (0, 3)]
77    result = list(offset_vertices_2d(source, offset=0.5, closed=True))
78
79.. image:: gfx/offset_vertices_2d_1.png
80
81Example for a closed collinear shape, which creates 2 additional vertices and the first one has an unexpected location:
82
83.. code-block:: Python
84
85    source = [(0, 0), (0, 1), (0, 2), (0, 3)]
86    result = list(offset_vertices_2d(source, offset=0.5, closed=True))
87
88.. image:: gfx/offset_vertices_2d_2.png
89
903D Functions
91============
92
93.. seealso::
94
95    The free online book `3D Math Primer for Graphics and Game Development <https://gamemath.com/>`_
96    is a very good resource for learning vector math and other graphic related topics,
97    it is easy to read for beginners and especially targeted to programmers.
98
99.. autofunction:: basic_transformation(move: Vertex = (0, 0, 0), scale: Vertex = (1, 1, 1), z_rotation: float = 0) -> Matrix44
100
101.. autofunction:: normal_vector_3p(a: Vec3, b: Vec3, c: Vec3) -> Vec3
102
103.. autofunction:: best_fit_normal(vertices: Iterable[Vertex]) -> Vec3
104
105.. autofunction:: is_planar_face(face: Sequence[Vec3], abs_tol=1e-9) -> bool
106
107.. autofunction:: subdivide_face(face: Sequence[Union[Vec3, Vec2]], quads=True) -> Iterable[List[Vec3]]
108
109.. autofunction:: subdivide_ngons(faces: Iterable[Sequence[Union[Vec3, Vec2]]]) -> Iterable[List[Vec3]]
110
111.. autofunction:: distance_point_line_3d(point: Vec3, start: Vec3, end: Vec3) -> float
112
113.. autofunction:: intersection_ray_ray_3d(ray1: Tuple[Vec3, Vec3], ray2: Tuple[Vec3, Vec3], abs_tol=1e-10) -> Sequence[Vec3]
114
115.. autofunction:: estimate_tangents(points: List[Vec3], method: str = '5-points', normalize = True) -> List[Vec3]
116
117.. autofunction:: estimate_end_tangent_magnitude(points: List[Vec3], method: str = 'chord') -> List[Vec3]
118
119.. autofunction:: fit_points_to_cad_cv
120
121.. autofunction:: fit_points_to_cubic_bezier
122
123.. autofunction:: global_bspline_interpolation
124
125.. autofunction:: local_cubic_bspline_interpolation(fit_points: Iterable[Vertex], method: str = '5-points', tangents :Iterable[Vertex] = None) -> BSpline
126
127.. autofunction:: rational_bspline_from_arc(center: Vec3 = (0, 0), radius:float=1, start_angle: float = 0, end_angle: float = 360, segments: int = 1) -> BSpline
128
129.. autofunction:: rational_bspline_from_ellipse(ellipse: ConstructionEllipse, segments: int = 1) -> BSpline
130
131.. autofunction:: open_uniform_bspline(control_points: Iterable[Vertex], order: int = 4, weights: Iterable[float] = None) -> BSpline
132
133.. autofunction:: closed_uniform_bspline(control_points: Iterable[Vertex], order: int = 4, weights: Iterable[float] = None) -> BSpline
134
135.. autofunction:: cubic_bezier_from_arc(center: Vec3 = (0, 0), radius:float=1, start_angle: float = 0, end_angle: float = 360, segments: int = 1) -> Iterable[Bezier4P]
136
137.. autofunction:: cubic_bezier_from_ellipse(ellipse: ConstructionEllipse, segments: int = 1) -> Iterable[Bezier4P]
138
139.. autofunction:: cubic_bezier_interpolation(points: Iterable[Vertex]) -> List[Bezier4P]
140
141.. autofunction:: quadratic_to_cubic_bezier(bezier: Bezier3P) -> Bezier4P
142
143.. autofunction:: bezier_to_bspline(Iterable[Union[Bezier3P, Bezier4P]], segments int = 4) -> BSpline
144
145.. autofunction:: have_bezier_curves_g1_continuity(b1: AnyBezier, b2 AnyBezier, g1_tol: float = 1e-4) -> bool
146
147Transformation Classes
148======================
149
150OCS Class
151---------
152
153.. autoclass:: OCS
154
155    .. autoattribute:: ux
156
157    .. autoattribute:: uy
158
159    .. autoattribute:: uz
160
161    .. automethod:: from_wcs
162
163    .. automethod:: points_from_wcs
164
165    .. automethod:: to_wcs
166
167    .. automethod:: points_to_wcs
168
169    .. automethod:: render_axis
170
171
172UCS Class
173---------
174
175.. autoclass:: UCS
176
177    .. autoattribute:: ux
178
179    .. autoattribute:: uy
180
181    .. autoattribute:: uz
182
183    .. autoattribute:: is_cartesian
184
185    .. automethod:: copy() -> UCS
186
187    .. automethod:: to_wcs
188
189    .. automethod:: points_to_wcs
190
191    .. automethod:: direction_to_wcs
192
193    .. automethod:: from_wcs
194
195    .. automethod:: points_from_wcs
196
197    .. automethod:: direction_from_wcs
198
199    .. automethod:: to_ocs
200
201    .. automethod:: points_to_ocs
202
203    .. automethod:: to_ocs_angle_deg
204
205    .. automethod:: transform(m: Matrix44) -> UCS
206
207    .. automethod:: rotate(axis: Vertex, angle:float) -> UCS
208
209    .. automethod:: rotate_local_x(angle:float) -> UCS
210
211    .. automethod:: rotate_local_y(angle:float) -> UCS
212
213    .. automethod:: rotate_local_z(angle:float) -> UCS
214
215    .. automethod:: shift(delta: Vertex) -> UCS
216
217    .. automethod:: moveto(location: Vertex) -> UCS
218
219    .. automethod:: from_x_axis_and_point_in_xy
220
221    .. automethod:: from_x_axis_and_point_in_xz
222
223    .. automethod:: from_y_axis_and_point_in_xy
224
225    .. automethod:: from_y_axis_and_point_in_yz
226
227    .. automethod:: from_z_axis_and_point_in_xz
228
229    .. automethod:: from_z_axis_and_point_in_yz
230
231    .. automethod:: render_axis
232
233
234Matrix44
235--------
236
237.. autoclass:: Matrix44
238
239    .. automethod:: __repr__
240
241    .. automethod:: get_row
242
243    .. automethod:: set_row
244
245    .. automethod:: get_col
246
247    .. automethod:: set_col
248
249    .. automethod:: copy() -> Matrix44
250
251    .. automethod:: __copy__() -> Matrix44
252
253    .. automethod:: scale(sx: float, sy: float = None, sz: float = None) -> Matrix44
254
255    .. automethod:: translate(dx: float, dy: float, dz: float) -> Matrix44
256
257    .. automethod:: x_rotate(angle: float) -> Matrix44
258
259    .. automethod:: y_rotate(angle: float) -> Matrix44
260
261    .. automethod:: z_rotate(angle: float) -> Matrix44
262
263    .. automethod:: axis_rotate(axis: Vertex, angle: float) -> Matrix44
264
265    .. automethod:: xyz_rotate(angle_x: float, angle_y: float, angle_z: float) -> Matrix44
266
267    .. automethod:: shear_xy(angle_x: float, angle_y: float) -> Matrix44
268
269    .. automethod:: perspective_projection(left: float, right: float, top: float, bottom: float, near: float, far: float) -> Matrix44
270
271    .. automethod:: perspective_projection_fov(fov: float, aspect: float, near: float, far: float) -> Matrix44
272
273    .. automethod:: chain(*matrices: Iterable[Matrix44]) -> Matrix44
274
275    .. automethod:: ucs(ux: Vertex, uy: Vertex, uz: Vertex) -> Matrix44
276
277    .. automethod:: __hash__
278
279    .. automethod:: __getitem__
280
281    .. automethod:: __setitem__
282
283    .. automethod:: __iter__
284
285    .. automethod:: rows
286
287    .. automethod:: columns
288
289    .. automethod:: __mul__(other: Matrix44) -> Matrix44
290
291    .. automethod:: __imul__(other: Matrix44) -> Matrix44
292
293    .. automethod:: transform
294
295    .. automethod:: transform_direction
296
297    .. automethod:: transform_vertices
298
299    .. automethod:: transform_directions
300
301    .. automethod:: transpose
302
303    .. automethod:: determinant
304
305    .. automethod:: inverse
306
307Construction Tools
308==================
309
310Vec3
311----
312
313.. autoclass:: Vec3
314
315    .. autoattribute:: x
316
317    .. autoattribute:: y
318
319    .. autoattribute:: z
320
321    .. autoattribute:: xy
322
323    .. autoattribute:: xyz
324
325    .. autoattribute:: vec2
326
327    .. autoattribute:: magnitude
328
329    .. autoattribute:: magnitude_xy
330
331    .. autoattribute:: magnitude_square
332
333    .. autoattribute:: is_null
334
335    .. autoattribute:: angle
336
337    .. autoattribute:: angle_deg
338
339    .. autoattribute:: spatial_angle
340
341    .. autoattribute:: spatial_angle_deg
342
343    .. automethod:: __str__
344
345    .. automethod:: __repr__
346
347    .. automethod:: __len__
348
349    .. automethod:: __hash__
350
351    .. automethod:: copy() -> Vec3
352
353    .. automethod:: __copy__() -> Vec3
354
355    .. automethod:: __deepcopy__(memodict: dict) -> Vec3
356
357    .. automethod:: __getitem__
358
359    .. automethod:: __iter__
360
361    .. automethod:: __abs__
362
363    .. automethod:: replace(x: float = None, y: float = None, z: float = None) -> Vec3
364
365    .. automethod:: generate(items: Iterable[Vertex]) -> Iterable[Vec3]
366
367    .. automethod:: list(items: Iterable[Vertex]) -> List[Vec3]
368
369    .. automethod:: tuple(items: Iterable[Vertex]) -> Sequence[Vec3]
370
371    .. automethod:: from_angle(angle: float, length: float = 1.) -> Vec3
372
373    .. automethod:: from_deg_angle(angle: float, length: float = 1.) -> Vec3
374
375    .. automethod:: orthogonal(ccw: bool = True) -> Vec3
376
377    .. automethod:: lerp(other: Vertex, factor=.5) -> Vec3
378
379    .. automethod:: is_parallel(other: Vec3, abs_tolr=1e-12) -> bool
380
381    .. automethod:: project(other: Vertex) -> Vec3
382
383    .. automethod:: normalize(length: float = 1.) -> Vec3
384
385    .. automethod:: reversed() -> Vec3
386
387    .. automethod:: isclose
388
389    .. automethod:: __neg__() -> Vec3
390
391    .. automethod:: __bool__
392
393    .. automethod:: __eq__
394
395    .. automethod:: __lt__
396
397    .. automethod:: __add__(other: Vertex) -> Vec3
398
399    .. automethod:: __radd__(other: Vertex) -> Vec3
400
401    .. automethod:: __sub__(other: Vertex) -> Vec3
402
403    .. automethod:: __rsub__(other: Vertex) -> Vec3
404
405    .. automethod:: __mul__(other: float) -> Vec3
406
407    .. automethod:: __rmul__(other: float) -> Vec3
408
409    .. automethod:: __truediv__(other: float) -> Vec3
410
411    .. automethod:: dot
412
413    .. automethod:: cross(other: Vertex) -> Vec3
414
415    .. automethod:: distance
416
417    .. automethod:: angle_about(base: Vec3, target: Vec3) -> float
418
419    .. automethod:: angle_between
420
421    .. automethod:: rotate(angle: float) -> Vec3
422
423    .. automethod:: rotate_deg(angle: float) -> Vec3
424
425    .. automethod:: sum(items: Iterable[Vertex]) -> Vec3
426
427.. attribute:: X_AXIS
428
429    :code:`Vec3(1, 0, 0)`
430
431.. attribute:: Y_AXIS
432
433    :code:`Vec3(0, 1, 0)`
434
435.. attribute:: Z_AXIS
436
437    :code:`Vec3(0, 0, 1)`
438
439.. attribute:: NULLVEC
440
441    :code:`Vec3(0, 0, 0)`
442
443Vec2
444----
445
446.. autoclass:: Vec2
447
448Plane
449-----
450
451.. autoclass:: Plane(normal: Vec3, distance: float)
452
453    .. autoattribute:: normal
454
455    .. autoattribute:: distance_from_origin
456
457    .. autoattribute:: vector
458
459    .. automethod:: from_3p(a: Vec3, b: Vec3, c: Vec3) -> Plane
460
461    .. automethod:: from_vector(vector) -> Plane
462
463    .. automethod:: copy() -> Plane
464
465    .. automethod:: signed_distance_to(v: Vec3) -> float
466
467    .. automethod:: distance_to(v: Vec3) -> float
468
469    .. automethod:: is_coplanar_vertex(v: Vec3, abs_tol=1e-9) -> bool
470
471    .. automethod:: is_coplanar_plane(p: Plane, abs_tol=1e-9) -> bool
472
473
474BoundingBox
475-----------
476
477.. autoclass:: BoundingBox
478
479    .. attribute:: extmin
480
481        "lower left" corner of bounding box
482
483    .. attribute:: extmax
484
485        "upper right" corner of bounding box
486
487    .. autoproperty:: is_empty
488
489    .. autoproperty:: has_data
490
491    .. autoproperty:: size
492
493    .. autoproperty:: center
494
495    .. automethod:: inside
496
497    .. automethod:: any_inside
498
499    .. automethod:: all_inside
500
501    .. automethod:: intersect(other: BoundingBox) -> bool
502
503    .. automethod:: extend
504
505    .. automethod:: union(other: BoundingBox) -> BoundingBox
506
507
508BoundingBox2d
509-------------
510
511.. autoclass:: BoundingBox2d
512
513    .. attribute:: extmin
514
515        "lower left" corner of bounding box
516
517    .. attribute:: extmax
518
519        "upper right" corner of bounding box
520
521    .. autoproperty:: is_empty
522
523    .. autoproperty:: has_data
524
525    .. autoproperty:: size
526
527    .. autoproperty:: center
528
529    .. automethod:: inside
530
531    .. automethod:: any_inside
532
533    .. automethod:: all_inside
534
535    .. automethod:: intersect(other: BoundingBox2d) -> bool
536
537    .. automethod:: extend
538
539    .. automethod:: union(other: BoundingBox2d) -> BoundingBox2d
540
541ConstructionRay
542---------------
543
544.. autoclass:: ConstructionRay
545
546    .. autoattribute:: location
547
548    .. autoattribute:: direction
549
550    .. autoattribute:: slope
551
552    .. autoattribute:: angle
553
554    .. autoattribute:: angle_deg
555
556    .. autoattribute:: is_vertical
557
558    .. autoattribute:: is_horizontal
559
560    .. automethod:: __str__
561
562    .. automethod:: is_parallel(self, other: ConstructionRay) -> bool
563
564    .. automethod:: intersect(other: ConstructionRay) -> Vec2
565
566    .. automethod:: orthogonal(location: 'Vertex') -> ConstructionRay
567
568    .. automethod:: bisectrix(other: ConstructionRay) -> ConstructionRay:
569
570    .. automethod:: yof
571
572    .. automethod:: xof
573
574ConstructionLine
575----------------
576
577.. autoclass:: ConstructionLine
578
579    .. attribute:: start
580
581        start point as :class:`Vec2`
582
583    .. attribute:: end
584
585        end point as :class:`Vec2`
586
587    .. autoattribute:: bounding_box
588
589    .. autoattribute:: ray
590
591    .. autoattribute:: is_vertical
592
593    .. autoattribute:: is_horizontal
594
595    .. automethod:: __str__
596
597    .. automethod:: translate
598
599    .. automethod:: length
600
601    .. automethod:: midpoint() -> Vec2
602
603    .. automethod:: inside_bounding_box
604
605    .. automethod:: intersect(other: ConstructionLine, abs_tol:float=1e-10) -> Optional[Vec2]
606
607    .. automethod:: has_intersection(other: ConstructionLine, abs_tol:float=1e-10) -> bool
608
609    .. automethod:: is_point_left_of_line
610
611
612ConstructionCircle
613------------------
614
615.. autoclass:: ConstructionCircle
616
617    .. attribute:: center
618
619        center point as :class:`Vec2`
620
621    .. attribute:: radius
622
623        radius as float
624
625    .. autoattribute:: bounding_box
626
627    .. automethod:: from_3p(p1: Vertex, p2: Vertex, p3: Vertex) -> ConstructionCircle
628
629    .. automethod:: __str__
630
631    .. automethod:: translate
632
633    .. automethod:: point_at(angle: float) -> Vec2
634
635    .. automethod:: inside
636
637    .. automethod:: tangent(angle: float) -> ConstructionRay
638
639    .. automethod:: intersect_ray(ray: ConstructionRay, abs_tol: float = 1e-10) -> Sequence[Vec2]
640
641    .. automethod:: intersect_circle(other: ConstructionCircle, abs_tol: float = 1e-10) -> Sequence[Vec2]
642
643ConstructionArc
644---------------
645
646.. autoclass:: ConstructionArc
647
648    .. attribute:: center
649
650        center point as :class:`Vec2`
651
652    .. attribute:: radius
653
654        radius as float
655
656    .. attribute:: start_angle
657
658        start angle in degrees
659
660    .. attribute:: end_angle
661
662        end angle in degrees
663
664    .. autoattribute:: angle_span
665
666    .. autoattribute:: start_angle_rad
667
668    .. autoattribute:: end_angle_rad
669
670    .. autoattribute:: start_point
671
672    .. autoattribute:: end_point
673
674    .. autoattribute:: bounding_box
675
676    .. automethod:: angles
677
678    .. automethod:: vertices
679
680    .. automethod:: tangents
681
682    .. automethod:: translate(dx: float, dy: float) -> ConstructionArc
683
684    .. automethod:: scale_uniform(s: float) -> ConstructionArc
685
686    .. automethod:: rotate_z(angle: float) -> ConstructionArc
687
688    .. automethod:: from_2p_angle(start_point: Vertex, end_point: Vertex, angle: float, ccw: bool = True) -> ConstructionArc
689
690    .. automethod:: from_2p_radius(start_point: Vertex, end_point: Vertex, radius: float, ccw: bool = True,  center_is_left: bool = True) -> ConstructionArc
691
692    .. automethod:: from_3p(start_point: Vertex, end_point: Vertex, def_point: Vertex, ccw: bool = True) -> ConstructionArc
693
694    .. automethod:: add_to_layout(layout: BaseLayout, ucs: UCS = None, dxfattribs: dict = None) -> Arc
695
696ConstructionEllipse
697-------------------
698
699.. autoclass:: ConstructionEllipse
700
701    .. attribute:: center
702
703        center point as :class:`Vec3`
704
705    .. attribute:: major_axis
706
707        major axis as :class:`Vec3`
708
709    .. attribute:: minor_axis
710
711        minor axis as :class:`Vec3`, automatically calculated from
712        :attr:`major_axis` and :attr:`extrusion`.
713
714    .. attribute:: extrusion
715
716        extrusion vector (normal of ellipse plane) as :class:`Vec3`
717
718    .. attribute:: ratio
719
720        ratio of minor axis to major axis (float)
721
722    .. attribute:: start
723
724        start param in radians (float)
725
726    .. attribute:: end
727
728        end param in radians (float)
729
730    .. autoattribute:: start_point
731
732    .. autoattribute:: end_point
733
734    .. autoproperty:: param_span
735
736    .. automethod:: to_ocs() -> ConstructionEllipse
737
738    .. automethod:: params
739
740    .. automethod:: vertices
741
742    .. automethod:: flattening
743
744    .. automethod:: params_from_vertices
745
746    .. automethod:: dxfattribs
747
748    .. automethod:: main_axis_points
749
750    .. automethod:: from_arc(center: Vertex=(0, 0, 0), radius: float = 1, extrusion: Vertex=(0, 0, 1), start_angle: float = 0, end_angle: float = 360, ccw: bool = True) -> ConstructionEllipse
751
752    .. automethod:: transform(m: Matrix44)
753
754    .. automethod:: swap_axis
755
756    .. automethod:: add_to_layout(layout: BaseLayout, dxfattribs: dict = None) -> Ellipse
757
758
759ConstructionBox
760---------------
761
762.. autoclass:: ConstructionBox
763
764    .. autoattribute:: center
765
766    .. autoattribute:: width
767
768    .. autoattribute:: height
769
770    .. autoattribute:: angle
771
772    .. autoattribute:: corners
773
774    .. autoattribute:: bounding_box
775
776    .. autoattribute:: incircle_radius
777
778    .. autoattribute:: circumcircle_radius
779
780    .. automethod:: __iter__() -> Iterable[Vec2]
781
782    .. automethod:: __getitem__(corner) -> Vec2
783
784    .. automethod:: __repr__
785
786    .. automethod:: from_points(p1: Vertex, p2: Vertex) -> ConstructionBox
787
788    .. automethod:: translate
789
790    .. automethod:: expand
791
792    .. automethod:: scale
793
794    .. automethod:: rotate
795
796    .. automethod:: is_inside
797
798    .. automethod:: is_any_corner_inside(other: ConstructionBox) -> bool
799
800    .. automethod:: is_overlapping(other: ConstructionBox) -> bool
801
802    .. automethod:: border_lines() -> Sequence[ConstructionLine]
803
804    .. automethod:: intersect(line: ConstructionLine) -> List[Vec2]
805
806Shape2d
807-------
808
809.. autoclass:: Shape2d
810
811    .. attribute:: vertices
812
813        List of :class:`Vec2` objects
814
815    .. autoattribute:: bounding_box
816
817    .. automethod:: __len__
818
819    .. automethod:: __getitem__(item) -> Vec2
820
821    .. automethod:: append
822
823    .. automethod:: extend
824
825    .. automethod:: translate
826
827    .. automethod:: scale
828
829    .. automethod:: scale_uniform
830
831    .. automethod:: rotate
832
833    .. automethod:: rotate_rad
834
835    .. automethod:: offset
836
837    .. automethod:: convex_hull
838
839Curves
840======
841
842BSpline
843-------
844
845.. autoclass:: BSpline
846
847    .. autoproperty:: control_points
848
849    .. autoproperty:: count
850
851    .. autoproperty:: order
852
853    .. autoproperty:: degree
854
855    .. autoproperty:: max_t
856
857    .. autoproperty:: is_rational
858
859    .. autoproperty:: is_clamped
860
861    .. automethod:: knots
862
863    .. automethod:: weights
864
865    .. automethod:: params
866
867    .. automethod:: reverse() -> BSpline
868
869    .. automethod:: transform(m: Matrix44) -> BSpline
870
871    .. automethod:: approximate(segments: int = 20) -> Iterable[Vec3]
872
873    .. automethod:: flattening(distance: float, segments: int = 4) -> Iterable[Vec3]
874
875    .. automethod:: point(t: float) -> Vec3
876
877    .. automethod:: points(t: float) -> List[Vec3]
878
879    .. automethod:: derivative(t: float, n: int=2) -> List[Vec3]
880
881    .. automethod:: derivatives(t: Iterable[float], n: int=2) -> Iterable[List[Vec3]]
882
883    .. automethod:: insert_knot(t: float) -> BSpline
884
885    .. automethod:: knot_refinement(u: Iterable[flat]) -> BSpline
886
887    .. automethod:: from_ellipse(ellipse: ConstructionEllipse) -> BSpline
888
889    .. automethod:: from_arc(arc: ConstructionArc) -> BSpline
890
891    .. automethod:: from_fit_points(points: Iterable[Vertex], degree:int=3, method='chord') -> BSpline
892
893    .. automethod:: arc_approximation(arc: ConstructionArc, num:int=16) -> BSpline
894
895    .. automethod:: ellipse_approximation(ellipse: ConstructionEllipse, num:int=16) -> BSpline
896
897    .. automethod:: bezier_decomposition() -> Iterable[List[Vec3]]
898
899    .. automethod:: cubic_bezier_approximation(level: int = 3, segments: int = None) -> Iterable[Bezier4P]
900
901
902Bezier
903------
904
905.. autoclass:: Bezier
906
907    .. autoattribute:: control_points
908
909    .. automethod:: params
910
911    .. automethod:: reverse() -> Bezier
912
913    .. automethod:: transform(m: Matrix44) -> Bezier
914
915    .. automethod:: approximate(segments: int = 20) -> Iterable[Vec3]
916
917    .. automethod:: flattening(distance: float, segments: int=4) -> Iterable[Vec3]
918
919    .. automethod:: point(t: float) -> Vec3
920
921    .. automethod:: points(t: Iterable[float]) -> Iterable[Vec3]
922
923    .. automethod:: derivative(t: float) -> Tuple[Vec3, Vec3, Vec3]
924
925    .. automethod:: derivatives(t: Iterable[float]) -> Iterable[Tuple[Vec3, Vec3, Vec3]]
926
927
928Bezier4P
929--------
930
931.. autoclass:: Bezier4P
932
933    .. autoattribute:: control_points
934
935    .. automethod:: reverse() -> Bezier4P
936
937    .. automethod:: transform(m: Matrix44) -> Bezier4P
938
939    .. automethod:: approximate(segments: int) -> Iterable[Union[Vec3, Vec2]]
940
941    .. automethod:: flattening(distance: float, segments: int=4) -> Iterable[Union[Vec3, Vec2]]
942
943    .. automethod:: approximated_length
944
945    .. automethod:: point(t: float) -> Union[Vec3, Vec2]
946
947    .. automethod:: tangent(t: float) -> Union[Vec3, Vec2]
948
949Bezier3P
950--------
951
952.. autoclass:: Bezier3P
953
954    .. autoattribute:: control_points
955
956    .. automethod:: reverse() -> Bezier3P
957
958    .. automethod:: transform(m: Matrix44) -> Bezier3P
959
960    .. automethod:: approximate(segments: int) -> Iterable[Union[Vec3, Vec2]]
961
962    .. automethod:: flattening(distance: float, segments: int=4) -> Iterable[Union[Vec3, Vec2]]
963
964    .. automethod:: approximated_length
965
966    .. automethod:: point(t: float) -> Union[Vec3, Vec2]
967
968    .. automethod:: tangent(t: float) -> Union[Vec3, Vec2]
969
970
971
972BezierSurface
973-------------
974
975.. autoclass:: BezierSurface
976
977    .. autoattribute:: nrows
978
979    .. autoattribute:: ncols
980
981    .. automethod:: point
982
983    .. automethod:: approximate
984
985
986EulerSpiral
987-----------
988
989.. autoclass:: EulerSpiral
990
991    .. automethod:: radius
992
993    .. automethod:: tangent(t: float) -> Vec3
994
995    .. automethod:: distance
996
997    .. automethod:: point(t: float) -> Vec3
998
999    .. automethod:: circle_center(t: float) -> Vec3
1000
1001    .. automethod:: approximate(length: float, segments: int) -> Iterable[Vec3]
1002
1003    .. automethod:: bspline(length: float, segments: int = 10, degree: int = 3, method: str = 'uniform') -> BSpline
1004
1005Linear Algebra
1006==============
1007
1008Functions
1009---------
1010
1011.. autofunction:: gauss_jordan_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> Tuple[Matrix, Matrix]
1012
1013.. autofunction:: gauss_jordan_inverse(A: Iterable[Iterable[float]]) -> Matrix
1014
1015.. autofunction:: gauss_vector_solver
1016
1017.. autofunction:: gauss_matrix_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> Matrix
1018
1019.. autofunction:: tridiagonal_vector_solver(A: Iterable[Iterable[float]], B: Iterable[float]) -> List[float]
1020
1021.. autofunction:: tridiagonal_matrix_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> Matrix
1022
1023.. autofunction:: banded_matrix(A: Matrix, check_all=True) -> Tuple[int, int]
1024
1025.. autofunction:: detect_banded_matrix(A: Matrix, check_all=True) -> Tuple[int, int]
1026
1027.. autofunction:: compact_banded_matrix(A: Matrix, m1: int, m2: int) -> Matrix
1028
1029.. autofunction:: freeze_matrix(A: Union[MatrixData, Matrix]) -> Matrix
1030
1031Matrix Class
1032------------
1033
1034.. autoclass:: Matrix
1035
1036    .. autoattribute:: nrows
1037
1038    .. autoattribute:: ncols
1039
1040    .. autoattribute:: shape
1041
1042    .. automethod:: reshape
1043
1044    .. automethod:: identity
1045
1046    .. automethod:: row
1047
1048    .. automethod:: iter_row
1049
1050    .. automethod:: col
1051
1052    .. automethod:: iter_col
1053
1054    .. automethod:: diag
1055
1056    .. automethod:: iter_diag
1057
1058    .. automethod:: rows
1059
1060    .. automethod:: cols
1061
1062    .. automethod:: set_row
1063
1064    .. automethod:: set_col
1065
1066    .. automethod:: set_diag
1067
1068    .. automethod:: append_row
1069
1070    .. automethod:: append_col
1071
1072    .. automethod:: swap_rows
1073
1074    .. automethod:: swap_cols
1075
1076    .. automethod:: transpose() -> Matrix
1077
1078    .. automethod:: inverse() -> Matrix
1079
1080    .. automethod:: determinant
1081
1082    .. automethod:: freeze() -> Matrix
1083
1084    .. automethod:: lu_decomp() -> LUDecomposition
1085
1086    .. automethod:: __getitem__(item: Tuple[int, int]) -> float
1087
1088    .. automethod:: __setitem__(item: Tuple[int, int], value: float)
1089
1090    .. automethod:: __eq__(other: Matrix) -> bool
1091
1092    .. automethod:: __add__(other: Union[Matrix, float]) -> Matrix
1093
1094    .. automethod:: __sub__(other: Union[Matrix, float]) -> Matrix
1095
1096    .. automethod:: __mul__(other: Union[Matrix, float]) -> Matrix
1097
1098
1099LUDecomposition Class
1100---------------------
1101
1102.. autoclass:: LUDecomposition
1103
1104    .. autoattribute:: nrows
1105
1106    .. automethod:: solve_vector
1107
1108    .. automethod:: solve_matrix(B: Iterable[Iterable[float]]) -> Matrix
1109
1110    .. automethod:: inverse() -> Matrix
1111
1112    .. automethod:: determinant
1113
1114BandedMatrixLU Class
1115--------------------
1116
1117.. autoclass:: BandedMatrixLU
1118
1119    .. attribute:: upper
1120
1121        Upper triangle
1122
1123    .. attribute:: lower
1124
1125        Lower triangle
1126
1127    .. attribute:: m1
1128
1129        Lower band count, excluding main matrix diagonal
1130
1131    .. attribute:: m2
1132
1133        Upper band count, excluding main matrix diagonal
1134
1135    .. attribute:: index
1136
1137        Swapped indices
1138
1139    .. autoattribute:: nrows
1140
1141    .. automethod:: solve_vector
1142
1143    .. automethod:: solve_matrix(B: Iterable[Iterable[float]]) -> Matrix
1144
1145    .. automethod:: determinant
1146
1147.. _Global Curve Interpolation: http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/CURVE-INT-global.html
1148.. _uniform: https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-uniform.html
1149.. _chord length: https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-chord-length.html
1150.. _centripetal: https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-centripetal.html
1151.. _knot: http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-knot-generation.html
1152.. _clamped curve: http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve.html
1153.. _open curve: http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve-open.html
1154.. _closed curve: http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve-closed.html
1155.. _basis: http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-basis_vector.html
1156.. _B-spline: https://en.wikipedia.org/wiki/B-spline
1157.. _Bézier curve: https://en.wikipedia.org/wiki/B%C3%A9zier_curve
1158.. _Lee Mac: http://www.lee-mac.com/bulgeconversion.html
1159.. _Gauss-Jordan: https://en.wikipedia.org/wiki/Gaussian_elimination
1160.. _Gauss-Elimination: https://en.wikipedia.org/wiki/Gaussian_elimination
1161.. _LU Decomposition: https://en.wikipedia.org/wiki/LU_decomposition
1162.. _sagitta: https://en.wikipedia.org/wiki/Sagitta_(geometry)