* rust side of circle args Signed-off-by: Jess Frazelle <github@jessfraz.com> * change circle in all test js files Signed-off-by: Jess Frazelle <github@jessfraz.com> * more js side Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * ud[ates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ud[ates Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
110 lines
172 KiB
Markdown
110 lines
172 KiB
Markdown
---
|
|
title: "rotate"
|
|
excerpt: "Rotate a solid."
|
|
layout: manual
|
|
---
|
|
|
|
Rotate a solid.
|
|
|
|
### Using Roll, Pitch, and Yaw
|
|
|
|
When rotating a part in 3D space, "roll," "pitch," and "yaw" refer to the three rotational axes used to describe its orientation: roll is rotation around the longitudinal axis (front-to-back), pitch is rotation around the lateral axis (wing-to-wing), and yaw is rotation around the vertical axis (up-down); essentially, it's like tilting the part on its side (roll), tipping the nose up or down (pitch), and turning it left or right (yaw).
|
|
|
|
So, in the context of a 3D model:
|
|
|
|
- **Roll**: Imagine spinning a pencil on its tip - that's a roll movement.
|
|
|
|
- **Pitch**: Think of a seesaw motion, where the object tilts up or down along its side axis.
|
|
|
|
- **Yaw**: Like turning your head left or right, this is a rotation around the vertical axis
|
|
|
|
### Using an Axis and Angle
|
|
|
|
When rotating a part around an axis, you specify the axis of rotation and the angle of rotation.
|
|
|
|
```js
|
|
rotate(
|
|
solid: Solid,
|
|
roll?: number,
|
|
pitch?: number,
|
|
yaw?: number,
|
|
axis?: [number],
|
|
angle?: number,
|
|
global?: bool,
|
|
) -> Solid
|
|
```
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `solid` | [`Solid`](/docs/kcl/types/Solid) | The solid to rotate. | Yes |
|
|
| `roll` | `number` | The roll angle in degrees. Must be used with `pitch` and `yaw`. Must be between -360 and 360. | No |
|
|
| `pitch` | `number` | The pitch angle in degrees. Must be used with `roll` and `yaw`. Must be between -360 and 360. | No |
|
|
| `yaw` | `number` | The yaw angle in degrees. Must be used with `roll` and `pitch`. Must be between -360 and 360. | No |
|
|
| `axis` | `[number]` | The axis to rotate around. Must be used with `angle`. | No |
|
|
| `angle` | `number` | The angle to rotate in degrees. Must be used with `axis`. Must be between -360 and 360. | No |
|
|
| `global` | `bool` | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No |
|
|
|
|
### Returns
|
|
|
|
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
// Rotate a pipe with roll, pitch, and yaw.
|
|
|
|
|
|
// Create a path for the sweep.
|
|
sweepPath = startSketchOn('XZ')
|
|
|> startProfileAt([0.05, 0.05], %)
|
|
|> line(end = [0, 7])
|
|
|> tangentialArc({ offset = 90, radius = 5 }, %)
|
|
|> line(end = [-3, 0])
|
|
|> tangentialArc({ offset = -90, radius = 5 }, %)
|
|
|> line(end = [0, 7])
|
|
|
|
// Create a hole for the pipe.
|
|
pipeHole = startSketchOn('XY')
|
|
|> circle(center = [0, 0], radius = 1.5)
|
|
|
|
sweepSketch = startSketchOn('XY')
|
|
|> circle(center = [0, 0], radius = 2)
|
|
|> hole(pipeHole, %)
|
|
|> sweep(path = sweepPath)
|
|
|> rotate(roll = 10, pitch = 10, yaw = 90)
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Rotate a pipe about an axis with an angle.
|
|
|
|
|
|
// Create a path for the sweep.
|
|
sweepPath = startSketchOn('XZ')
|
|
|> startProfileAt([0.05, 0.05], %)
|
|
|> line(end = [0, 7])
|
|
|> tangentialArc({ offset = 90, radius = 5 }, %)
|
|
|> line(end = [-3, 0])
|
|
|> tangentialArc({ offset = -90, radius = 5 }, %)
|
|
|> line(end = [0, 7])
|
|
|
|
// Create a hole for the pipe.
|
|
pipeHole = startSketchOn('XY')
|
|
|> circle(center = [0, 0], radius = 1.5)
|
|
|
|
sweepSketch = startSketchOn('XY')
|
|
|> circle(center = [0, 0], radius = 2)
|
|
|> hole(pipeHole, %)
|
|
|> sweep(path = sweepPath)
|
|
|> rotate(axis = [0, 0, 1.0], angle = 90)
|
|
```
|
|
|
|

|
|
|
|
|