Hello,
I have a vector containing 2D vectors (points), such as:
my_points[[0,0],[0,1],[1,1], [1,0]];
Now I want to move all the points by addition of a vector.
I have tried this:
for (i = [0:len(my_points)]) {
my_points[i] += [-133.7/2, 0];
}
However, the line "my_points[i] += [-133.7/2, 0];" triggers a syntax error
message. What's wrong?
--
Sent from: http://forum.openscad.org/
Variables in OpenSCAD are immutable, so really named constants. So there
are no += or -= operators, hence the syntax error.
you could do:
moved_points = [for(p = my_points) p + [-133.7/2, 0] ];
On Fri, 26 Jun 2020 at 10:25, amundsen roald.baudoux@brutele.be wrote:
Hello,
I have a vector containing 2D vectors (points), such as:
my_points[[0,0],[0,1],[1,1], [1,0]];
Now I want to move all the points by addition of a vector.
I have tried this:
for (i = [0:len(my_points)]) {
my_points[i] += [-133.7/2, 0];
}
However, the line "my_points[i] += [-133.7/2, 0];" triggers a syntax error
message. What's wrong?
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Can't I modify the points in place?
--
Sent from: http://forum.openscad.org/
Ok, this code still triggers an error message:
pqr = [[0,1],[1,1],[1,0],[0,0]];
px = [for(p = pqr]) p + [-133.7/2, 0]];
The error pointer is inserted on the "r" of "for". I really have no clue
about what is wrong now.
--
Sent from: http://forum.openscad.org/
Mismatched brackets?
On 6/26/2020 12:54 PM, amundsen wrote:
Ok, this code still triggers an error message:
pqr = [[0,1],[1,1],[1,0],[0,0]];
px = [for(p = pqr]) p + [-133.7/2, 0]];
The error pointer is inserted on the "r" of "for". I really have no clue
about what is wrong now.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
.
px = [for(p = pqr]) p + [-133.7/2, 0]];
^-- delete ']'
-----Original Message-----
From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of amundsen
Sent: Fri, 26 Jun 2020 19:55
Subject: Re: [OpenSCAD] Issue with simple 2D vector addition
Ok, this code still triggers an error message:
pqr = [[0,1],[1,1],[1,0],[0,0]];
px = [for(p = pqr]) p + [-133.7/2, 0]];
The error pointer is inserted on the "r" of "for". I really have no clue
about what is wrong now.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
--
This email has been checked for viruses by AVG.
https://www.avg.com