Move axes to std constants; move helix, revolve, and mirror2d to be declated in KCL Signed-off-by: Nick Cameron <nrc@ncameron.org>
99 lines
284 KiB
Markdown
99 lines
284 KiB
Markdown
---
|
|
title: "std::sketch::mirror2d"
|
|
excerpt: "Mirror a sketch."
|
|
layout: manual
|
|
---
|
|
|
|
Mirror a sketch.
|
|
|
|
Only works on unclosed sketches for now.
|
|
|
|
Mirror occurs around a local sketch axis rather than a global axis.
|
|
|
|
```js
|
|
mirror2d(@sketches: [Sketch; 1+], axis: Axis2d | Edge): Sketch
|
|
```
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `sketches` | `[Sketch; 1+]` | The sketch or sketches to be reflected. | Yes |
|
|
| `axis` | `Axis2d | Edge` | The axis to reflect around. | Yes |
|
|
|
|
### Returns
|
|
|
|
[`Sketch`](/docs/kcl/types/Sketch)
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
// Mirror an un-closed sketch across the Y axis.
|
|
sketch001 = startSketchOn(XZ)
|
|
|> startProfileAt([0, 10], %)
|
|
|> line(end = [15, 0])
|
|
|> line(end = [-7, -3])
|
|
|> line(end = [9, -1])
|
|
|> line(end = [-8, -5])
|
|
|> line(end = [9, -3])
|
|
|> line(end = [-8, -3])
|
|
|> line(end = [9, -1])
|
|
|> line(end = [-19, -0])
|
|
|> mirror2d(axis = Y)
|
|
|
|
example = extrude(sketch001, length = 10)
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Mirror a un-closed sketch across the Y axis.
|
|
sketch001 = startSketchOn(XZ)
|
|
|> startProfileAt([0, 8.5], %)
|
|
|> line(end = [20, -8.5])
|
|
|> line(end = [-20, -8.5])
|
|
|> mirror2d(axis = Y)
|
|
|
|
example = extrude(sketch001, length = 10)
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Mirror a un-closed sketch across an edge.
|
|
helper001 = startSketchOn(XZ)
|
|
|> startProfileAt([0, 0], %)
|
|
|> line(end = [0, 10], tag = $edge001)
|
|
|
|
sketch001 = startSketchOn(XZ)
|
|
|> startProfileAt([0, 8.5], %)
|
|
|> line(end = [20, -8.5])
|
|
|> line(end = [-20, -8.5])
|
|
|> mirror2d(axis = edge001)
|
|
|
|
// example = extrude(sketch001, length = 10)
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Mirror an un-closed sketch across a custom axis.
|
|
sketch001 = startSketchOn(XZ)
|
|
|> startProfileAt([0, 8.5], %)
|
|
|> line(end = [20, -8.5])
|
|
|> line(end = [-20, -8.5])
|
|
|> mirror2d(
|
|
axis = {
|
|
direction = [0.0, 1.0],
|
|
origin = [0.0, 0.0]
|
|
})
|
|
|
|
example = extrude(sketch001, length = 10)
|
|
```
|
|
|
|

|
|
|
|
|