Fix tanArcTo (#3318)

* updated tangentArc math

* Add a test case showing tan arc then xLineTo

* Fix compile errors

* Tweaking the math

* Use + on angles

* atan2 outputs radians, not degrees

* Track ccw and center of all tan arcs

* re-sequenced atan2 arcTan

* Remove print statements

* Update the test

* Update kittycad in tauri

* New arc fields

---------

Co-authored-by: Jordan Noone <jordan@kittycad.io>
This commit is contained in:
Adam Chalmers
2024-08-07 18:35:41 -05:00
committed by GitHub
parent 6773dbe7ff
commit 6f4bbdb79e
49 changed files with 2700 additions and 26 deletions

View File

@ -253,6 +253,10 @@ const extrusion = extrude(5, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -458,6 +462,10 @@ const extrusion = extrude(5, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -257,6 +257,10 @@ const extrusion = extrude(5, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -462,6 +466,10 @@ const extrusion = extrude(5, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -172,6 +172,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -377,6 +381,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -584,6 +592,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -789,6 +801,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -171,6 +171,10 @@ const extrusion = extrude(10, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -376,6 +380,10 @@ const extrusion = extrude(10, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -583,6 +591,10 @@ const extrusion = extrude(10, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -788,6 +800,10 @@ const extrusion = extrude(10, sketch001)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -173,6 +173,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -378,6 +382,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -585,6 +593,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -790,6 +802,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -265,6 +265,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -470,6 +474,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -677,6 +685,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -882,6 +894,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -170,6 +170,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -375,6 +379,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -582,6 +590,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -787,6 +799,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -170,6 +170,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -375,6 +379,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -582,6 +590,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -787,6 +799,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -183,6 +183,10 @@ const exampleSketch = startSketchOn('XZ')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -388,6 +392,10 @@ const exampleSketch = startSketchOn('XZ')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -595,6 +603,10 @@ const exampleSketch = startSketchOn('XZ')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -800,6 +812,10 @@ const exampleSketch = startSketchOn('XZ')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -176,6 +176,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -381,6 +385,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -588,6 +596,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -793,6 +805,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -398,6 +398,10 @@ const mountingPlate = extrude(thickness, mountingPlateSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -798,6 +802,10 @@ const mountingPlate = extrude(thickness, mountingPlateSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -169,6 +169,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -541,6 +545,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -748,6 +756,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -953,6 +965,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -171,6 +171,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -376,6 +380,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -583,6 +591,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -788,6 +800,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -196,6 +196,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -402,6 +406,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -728,6 +736,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -398,6 +398,10 @@ const mountingPlate = extrude(thickness, mountingPlateSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -798,6 +802,10 @@ const mountingPlate = extrude(thickness, mountingPlateSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -299,6 +299,10 @@ const part001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -690,6 +694,10 @@ const part001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -182,6 +182,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -388,6 +392,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -586,6 +594,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -791,6 +803,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -989,6 +1005,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -1194,6 +1214,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -162,6 +162,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -367,6 +371,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -162,6 +162,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -367,6 +371,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -175,6 +175,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -380,6 +384,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -587,6 +595,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -792,6 +804,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -162,6 +162,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -367,6 +371,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -574,6 +582,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -779,6 +791,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -180,6 +180,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -386,6 +390,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -304,6 +304,10 @@ const example = extrude(-5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -173,6 +173,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -379,6 +383,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -302,6 +302,10 @@ const example = extrude(1, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -304,6 +304,10 @@ let vase = layer()
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -163,6 +163,10 @@ const sketch001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -368,6 +372,10 @@ const sketch001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -158,6 +158,10 @@ const sketch001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -363,6 +367,10 @@ const sketch001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -157,6 +157,10 @@ const sketch001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -362,6 +366,10 @@ const sketch001 = startSketchOn('XY')
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -379,6 +379,10 @@ uuid |
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -584,6 +588,10 @@ uuid |
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -907,6 +915,10 @@ uuid |
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -386,6 +386,10 @@ shell({ faces: ['end'], thickness: 0.25 }, firstSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -777,6 +781,10 @@ shell({ faces: ['end'], thickness: 0.25 }, firstSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -241,6 +241,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -540,6 +544,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -745,6 +753,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -188,6 +188,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -393,6 +397,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -310,6 +310,10 @@ const a1 = startSketchOn({
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -722,6 +726,10 @@ const a1 = startSketchOn({
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

File diff suppressed because it is too large Load Diff

View File

@ -172,6 +172,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -377,6 +381,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -584,6 +592,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -789,6 +801,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -162,6 +162,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -367,6 +371,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -574,6 +582,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -779,6 +791,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -165,6 +165,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -370,6 +374,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -577,6 +585,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -782,6 +794,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -165,6 +165,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -370,6 +374,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -577,6 +585,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -782,6 +794,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -163,6 +163,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -368,6 +372,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -575,6 +583,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -780,6 +792,10 @@ const example = extrude(10, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

View File

@ -161,6 +161,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -366,6 +370,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -573,6 +581,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
@ -778,6 +790,10 @@ const example = extrude(5, exampleSketch)
type: "TangentialArcTo",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.

4
src-tauri/Cargo.lock generated
View File

@ -2672,9 +2672,9 @@ dependencies = [
[[package]]
name = "kittycad"
version = "0.3.9"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36b87a9cca545825ba18005c1944b8525fac28867d99984178bf22c79fb5ec25"
checksum = "3d798c82f6e62d786fca0a7ec073675bbe9550c885efb99390d2701ca557ec69"
dependencies = [
"anyhow",
"async-trait",

View File

@ -1480,9 +1480,9 @@ dependencies = [
[[package]]
name = "kittycad"
version = "0.3.9"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36b87a9cca545825ba18005c1944b8525fac28867d99984178bf22c79fb5ec25"
checksum = "3d798c82f6e62d786fca0a7ec073675bbe9550c885efb99390d2701ca557ec69"
dependencies = [
"anyhow",
"async-trait",
@ -1858,7 +1858,7 @@ dependencies = [
"bincode",
"either",
"fnv",
"itertools 0.12.1",
"itertools 0.10.5",
"lazy_static",
"nom",
"quick-xml",

View File

@ -1017,6 +1017,11 @@ impl SketchGroup {
};
};
match path {
Path::TangentialArc { center, ccw, .. } => GetTangentialInfoFromPathsResult {
center_or_tangent_point: *center,
is_center: true,
ccw: *ccw,
},
Path::TangentialArcTo { center, ccw, .. } => GetTangentialInfoFromPathsResult {
center_or_tangent_point: *center,
is_center: true,
@ -1346,6 +1351,11 @@ pub enum Path {
TangentialArc {
#[serde(flatten)]
base: BasePath,
/// the arc's center
#[ts(type = "[number, number]")]
center: [f64; 2],
/// arc's direction
ccw: bool,
},
/// A path that is horizontal.
Horizontal {
@ -1378,7 +1388,7 @@ impl Path {
Path::AngledLineTo { base, .. } => base.geo_meta.id,
Path::Base { base } => base.geo_meta.id,
Path::TangentialArcTo { base, .. } => base.geo_meta.id,
Path::TangentialArc { base } => base.geo_meta.id,
Path::TangentialArc { base, .. } => base.geo_meta.id,
}
}
@ -1389,7 +1399,7 @@ impl Path {
Path::AngledLineTo { base, .. } => base.tag.clone(),
Path::Base { base } => base.tag.clone(),
Path::TangentialArcTo { base, .. } => base.tag.clone(),
Path::TangentialArc { base } => base.tag.clone(),
Path::TangentialArc { base, .. } => base.tag.clone(),
}
}
@ -1400,7 +1410,7 @@ impl Path {
Path::AngledLineTo { base, .. } => base,
Path::Base { base } => base,
Path::TangentialArcTo { base, .. } => base,
Path::TangentialArc { base } => base,
Path::TangentialArc { base, .. } => base,
}
}
@ -1411,7 +1421,7 @@ impl Path {
Path::AngledLineTo { base, .. } => Some(base),
Path::Base { base } => Some(base),
Path::TangentialArcTo { base, .. } => Some(base),
Path::TangentialArc { base } => Some(base),
Path::TangentialArc { base, .. } => Some(base),
}
}
}

View File

@ -1681,42 +1681,65 @@ async fn inner_tangential_arc(
args: Args,
) -> Result<Box<SketchGroup>, KclError> {
let from: Point2d = sketch_group.current_pen_position()?;
// next set of lines is some undocumented voodoo from get_tangential_arc_to_info
let tangent_info = sketch_group.get_tangential_info_from_paths(); //this function desperately needs some documentation
let tan_previous_point = if tangent_info.is_center {
get_tangent_point_from_previous_arc(tangent_info.center_or_tangent_point, tangent_info.ccw, from.into())
} else {
tangent_info.center_or_tangent_point
};
let id = uuid::Uuid::new_v4();
let to = match &data {
let (center, to, ccw) = match data {
TangentialArcData::RadiusAndOffset { radius, offset } => {
// KCL stdlib types use degrees.
let offset = Angle::from_degrees(offset);
// Calculate the end point from the angle and radius.
let end_angle = Angle::from_degrees(*offset);
let start_angle = Angle::from_degrees(0.0);
let (_, to) = arc_center_and_end(from, start_angle, end_angle, *radius);
// atan2 outputs radians.
let previous_end_tangent = Angle::from_radians(f64::atan2(
from.y - tan_previous_point[1],
from.x - tan_previous_point[0],
));
// make sure the arc center is on the correct side to guarantee deterministic behavior
// note the engine automatically rejects an offset of zero, if we want to flag that at KCL too to avoid engine errors
let ccw = offset.degrees() > 0.0;
let tangent_to_arc_start_angle = if ccw {
// CCW turn
Angle::from_degrees(-90.0)
} else {
// CW turn
Angle::from_degrees(90.0)
};
// may need some logic and / or modulo on the various angle values to prevent them from going "backwards"
// but the above logic *should* capture that behavior
let start_angle = previous_end_tangent + tangent_to_arc_start_angle;
let end_angle = start_angle + offset;
let (center, to) = arc_center_and_end(from, start_angle, end_angle, radius);
args.batch_modeling_cmd(
id,
ModelingCmd::ExtendPath {
path: sketch_group.id,
segment: kittycad::types::PathSegment::TangentialArc {
radius: *radius,
offset: Angle {
unit: kittycad::types::UnitAngle::Degrees,
value: *offset,
},
},
segment: kittycad::types::PathSegment::TangentialArc { radius, offset },
},
)
.await?;
to.into()
(center, to.into(), ccw)
}
TangentialArcData::Point(to) => {
args.batch_modeling_cmd(id, tan_arc_to(&sketch_group, to)).await?;
*to
args.batch_modeling_cmd(id, tan_arc_to(&sketch_group, &to)).await?;
// TODO: Figure out these calculations.
let ccw = false;
let center = Point2d { x: 0.0, y: 0.0 };
(center, to, ccw)
}
};
let to = [from.x + to[0], from.y + to[1]];
let current_path = Path::TangentialArc {
ccw,
center: center.into(),
base: BasePath {
from: from.into(),
to,

View File

@ -833,6 +833,7 @@ pub fn get_tangent_point_from_previous_arc(
) -> Coords2d {
let angle_from_old_center_to_arc_start = get_angle(last_arc_center, last_arc_end);
let tangential_angle = angle_from_old_center_to_arc_start + if last_arc_ccw { -90.0 } else { 90.0 };
// What is the 10.0 constant doing???
[
tangential_angle.to_radians().cos() * 10.0 + last_arc_end[0],
tangential_angle.to_radians().sin() * 10.0 + last_arc_end[1],

View File

@ -0,0 +1,25 @@
let startX = 0
let startY = 0
let angleOffset = 135
let r = 1
let angleStart = 110
startSketchOn('XY')
|> startProfileAt([startX, startY], %)
|> angledLine({
angle: angleStart,
length: .000001,
}, %)
|> tangentialArc({
offset: angleOffset,
radius: r,
}, %, $arc1)
|> tangentialArc({
offset: angleOffset,
radius: 0.5*r,
}, %, $arc2)
|> tangentialArc({
offset: -angleOffset,
radius: 0.5*r,
}, %, $arc3)
|> xLineTo(1, %)

View File

@ -31,6 +31,13 @@ async fn kcl_test_riddle_small() {
assert_out("riddle_small", &result);
}
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_tan_arc_x_line() {
let code = kcl_input!("tan_arc_x_line");
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("tan_arc_x_line", &result);
}
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_lego() {
let code = kcl_input!("lego");

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB