Irev-Dev / Irev-Dev/Round-Anything

Helpers for converting [x, y] tuples to [x, y, r] tuples and back

Open
#27 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
OpenSCAD
Stars
677
Forks
52
PR merge metrics
No merged PRs in 30d

Description

One of the consistent API pain points I have is moving between an [x, y] and [x, y, r] coordinate lists. I frequently find I want to start with a polygon in [x, y] space while developing iteratively, and only later move it to an [x, y, r] polygon. Additionally, I've wanted to use `translateRadiiPoints` for regular [x, y] polygons before. Here are two (dumb, simple) helper functions that I frequently use; I think Round-Anything could benefit from similar (better-named) functions.

```
function rless(list) = [for (i=[0:len(list)-1]) [list[i][0], list[i][1]]] ;
function rish(list, r) = [for (i=[0:len(list)-1]) [list[i][0], list[i][1], r]] ;
```

Example where `rless` is helpful:
```
portWidth = 5;
portHeight = 12.50;
points = [
[0, 0, 2],
[0, portHeight, 2],
[portWidth, portHeight, 2],
[portWidth, 0, 2],
];

polygon(rless(points));
```

And for `rish`:
```
portWidth = 5;
portHeight = 12.50;
points = [
[0, 0],
[0, portHeight],
[portWidth, portHeight],
[portWidth, 0],
];

polygon(rless(translateRadiiPoints(rish(points, 0)));
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.