RW
Raymond West
Mon, Jun 24, 2024 7:37 PM
Hi, I've been measuring some buildings, by walking around the sides with
a tape measure. I've recorded the measurements in a notebook, with a
rough outline. The easiest way I can think of is entering the data is as
a comma separated string, something like "e500, n30,e70.5, e80", etc.
where the letters signify direction, east, west, north, south (assuming
building is square, but maybe it needs a rethink, with just a compass
bearing in degrees, say, instead of the letters - would be useful for
bay windows, etc.) However, in order to get an external floor plan, I
need it to be converted to a list of vectors - in the above example it
would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If I've added it up
correctly). However, I'm struggling to do that within openscad.
The number of measurements involved, makes it tedious to enter the list
syntax directly. Any ideas on how to do the conversion within openscad?
I want to minimise the keystrokes for data entry.
Best wishes,
Ray
Hi, I've been measuring some buildings, by walking around the sides with
a tape measure. I've recorded the measurements in a notebook, with a
rough outline. The easiest way I can think of is entering the data is as
a comma separated string, something like "e500, n30,e70.5, e80", etc.
where the letters signify direction, east, west, north, south (assuming
building is square, but maybe it needs a rethink, with just a compass
bearing in degrees, say, instead of the letters - would be useful for
bay windows, etc.) However, in order to get an external floor plan, I
need it to be converted to a list of vectors - in the above example it
would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If I've added it up
correctly). However, I'm struggling to do that within openscad.
The number of measurements involved, makes it tedious to enter the list
syntax directly. Any ideas on how to do the conversion within openscad?
I want to minimise the keystrokes for data entry.
Best wishes,
Ray
JB
Jon Bondy
Mon, Jun 24, 2024 7:44 PM
Given a list of numbers, I use editor macros (in my own editor) to put
them in a format that OpenSCAD likes. Is this the problem you are
trying to solve?
Jon
On 6/24/2024 3:37 PM, Raymond West via Discuss wrote:
Hi, I've been measuring some buildings, by walking around the sides
with a tape measure. I've recorded the measurements in a notebook,
with a rough outline. The easiest way I can think of is entering the
data is as a comma separated string, something like "e500, n30,e70.5,
e80", etc. where the letters signify direction, east, west, north,
south (assuming building is square, but maybe it needs a rethink, with
just a compass bearing in degrees, say, instead of the letters - would
be useful for bay windows, etc.) However, in order to get an external
floor plan, I need it to be converted to a list of vectors - in the
above example it would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If
I've added it up correctly). However, I'm struggling to do that within
openscad.
The number of measurements involved, makes it tedious to enter the
list syntax directly. Any ideas on how to do the conversion within
openscad? I want to minimise the keystrokes for data entry.
Best wishes,
Ray
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
Given a list of numbers, I use editor macros (in my own editor) to put
them in a format that OpenSCAD likes. Is this the problem you are
trying to solve?
Jon
On 6/24/2024 3:37 PM, Raymond West via Discuss wrote:
> Hi, I've been measuring some buildings, by walking around the sides
> with a tape measure. I've recorded the measurements in a notebook,
> with a rough outline. The easiest way I can think of is entering the
> data is as a comma separated string, something like "e500, n30,e70.5,
> e80", etc. where the letters signify direction, east, west, north,
> south (assuming building is square, but maybe it needs a rethink, with
> just a compass bearing in degrees, say, instead of the letters - would
> be useful for bay windows, etc.) However, in order to get an external
> floor plan, I need it to be converted to a list of vectors - in the
> above example it would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If
> I've added it up correctly). However, I'm struggling to do that within
> openscad.
>
> The number of measurements involved, makes it tedious to enter the
> list syntax directly. Any ideas on how to do the conversion within
> openscad? I want to minimise the keystrokes for data entry.
>
> Best wishes,
>
> Ray
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
SL
Steve Lelievre
Mon, Jun 24, 2024 7:50 PM
A quick and lazy way that I think would work if you don't mind typing
one extra multiply symbol per coordinate would be to:
define variables n as [0,1], s as [0, -1], e as [1,0] and w as [-1,0]
then type in your coordinates as a vector [e500, n30, e70.5, e80]
then sum the elements from 0 to n to get successive elements of your
output vector.
Steve
On 2024-06-24 12:37 p.m., Raymond West via Discuss wrote:
Hi, I've been measuring some buildings, by walking around the sides
with a tape measure. I've recorded the measurements in a notebook,
with a rough outline. The easiest way I can think of is entering the
data is as a comma separated string, something like "e500, n30,e70.5,
e80", etc. where the letters signify direction, east, west, north,
south (assuming building is square, but maybe it needs a rethink, with
just a compass bearing in degrees, say, instead of the letters - would
be useful for bay windows, etc.) However, in order to get an external
floor plan, I need it to be converted to a list of vectors - in the
above example it would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If
I've added it up correctly). However, I'm struggling to do that within
openscad.
The number of measurements involved, makes it tedious to enter the
list syntax directly. Any ideas on how to do the conversion within
openscad? I want to minimise the keystrokes for data entry.
Best wishes,
Ray
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
A quick and lazy way that I think would work if you don't mind typing
one extra multiply symbol per coordinate would be to:
define variables n as [0,1], s as [0, -1], e as [1,0] and w as [-1,0]
then type in your coordinates as a vector [e*500, n*30, e*70.5, e*80]
then sum the elements from 0 to n to get successive elements of your
output vector.
Steve
On 2024-06-24 12:37 p.m., Raymond West via Discuss wrote:
> Hi, I've been measuring some buildings, by walking around the sides
> with a tape measure. I've recorded the measurements in a notebook,
> with a rough outline. The easiest way I can think of is entering the
> data is as a comma separated string, something like "e500, n30,e70.5,
> e80", etc. where the letters signify direction, east, west, north,
> south (assuming building is square, but maybe it needs a rethink, with
> just a compass bearing in degrees, say, instead of the letters - would
> be useful for bay windows, etc.) However, in order to get an external
> floor plan, I need it to be converted to a list of vectors - in the
> above example it would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If
> I've added it up correctly). However, I'm struggling to do that within
> openscad.
>
> The number of measurements involved, makes it tedious to enter the
> list syntax directly. Any ideas on how to do the conversion within
> openscad? I want to minimise the keystrokes for data entry.
>
> Best wishes,
>
> Ray
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
--
https://www.gnomoni.ca
https://www.youtube.com/@gnomonica
JB
Jordan Brown
Mon, Jun 24, 2024 8:21 PM
On 6/24/2024 12:37 PM, Raymond West via Discuss wrote:
Hi, I've been measuring some buildings, by walking around the sides
with a tape measure. I've recorded the measurements in a notebook,
with a rough outline. The easiest way I can think of is entering the
data is as a comma separated string, something like "e500, n30,e70.5,
e80", etc. where the letters signify direction, east, west, north,
south (assuming building is square, but maybe it needs a rethink, with
just a compass bearing in degrees, say, instead of the letters - would
be useful for bay windows, etc.) However, in order to get an external
floor plan, I need it to be converted to a list of vectors - in the
above example it would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If
I've added it up correctly). However, I'm struggling to do that within
openscad.
The number of measurements involved, makes it tedious to enter the
list syntax directly. Any ideas on how to do the conversion within
openscad? I want to minimise the keystrokes for data entry.
For a non-DIY solution, consider BOSL2's turtle-graphics function:
https://github.com/BelfrySCAD/BOSL2/wiki/drawing.scad#function-turtle
ISTM that there are approximately three steps to the problem you're
describing.
- Converting a string like "e500, n30, e70.5, e80" into something more
directly usable, like a list of compass bearings and distances.
- Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
- Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
For my own house model, my biggest tool was my "vector" function:
function vector(origin, dir, length) = polaradd(origin, fromcompass(dir), length);
function polaradd(origin, dir, length) =
[origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
function fromcompass(a) = normalize_angle(90+360-a);
// Normalize an angle so that it is between 0..360
function normalize_angle(a) = (a%360 + 360)%360;
so if I was describing the path you described above, it would end up
something like:
p1 = [0,0];
p2 = vector(p1, 90, 500);
p3 = vector(p2, 0, 30);
p4 = vector(p3, 90, 70.5);
p5 = vector(p4, 90, 80);
That's a very verbose representation, but (a) the typing was only a very
small fraction of the cost, and (b) it allowed me to base multiple
"next" points on a single point. That is, if I needed to also go west
from point 3, that was straightforward. I can provide additional
details on how I represented walls if you like.
But going back to your question...
- Converting a string like "e500, n30, e70.5, e80" into something more
directly usable, like a list of compass bearings and distances.
I would do this in preprocessing, rather than trying to do it in
OpenSCAD per se. You certainly can do such things in OpenSCAD, but it
is no fun at all.I would use an editor (vi, sed, et cetera) or maybe a
text-friendly programming language to add in the brackets and turn
"eNNN" to "90, NNN".
- Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
cartesian_relative = [ for (p=polar_relative) p[1] * [cos(p[0]), sin(p[0])] ];
- Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
This is a variation on the classic "running sum" problem, which is never
any fun. (But not quite common enough or un-fun enough for me to have a
stock solution anywhere.)
Here's a solution, though I'm not entirely happy with it. I think it
can be optimized a bit but don't have the energy right now:
function runningSum(a, i=0) =
[
a[0],
for ( i = 0, t = a[0]; i+1 < len(a); i=i+1, t=t+a[i]) t + a[i]
];
Notes:
* I didn't want to have it know what type the array is - it should
be anything that you can add: numbers, vec2s, vec3s, et cetera.
* It needs to emit the last entry *without* stepping past the end
of the array.
On 6/24/2024 12:37 PM, Raymond West via Discuss wrote:
> Hi, I've been measuring some buildings, by walking around the sides
> with a tape measure. I've recorded the measurements in a notebook,
> with a rough outline. The easiest way I can think of is entering the
> data is as a comma separated string, something like "e500, n30,e70.5,
> e80", etc. where the letters signify direction, east, west, north,
> south (assuming building is square, but maybe it needs a rethink, with
> just a compass bearing in degrees, say, instead of the letters - would
> be useful for bay windows, etc.) However, in order to get an external
> floor plan, I need it to be converted to a list of vectors - in the
> above example it would be [[500,0],[530,30],[570.5,30],[650.5,30]] (If
> I've added it up correctly). However, I'm struggling to do that within
> openscad.
>
> The number of measurements involved, makes it tedious to enter the
> list syntax directly. Any ideas on how to do the conversion within
> openscad? I want to minimise the keystrokes for data entry.
For a non-DIY solution, consider BOSL2's turtle-graphics function:
https://github.com/BelfrySCAD/BOSL2/wiki/drawing.scad#function-turtle
ISTM that there are approximately three steps to the problem you're
describing.
* Converting a string like "e500, n30, e70.5, e80" into something more
directly usable, like a list of compass bearings and distances.
* Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
* Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
For my own house model, my biggest tool was my "vector" function:
function vector(origin, dir, length) = polaradd(origin, fromcompass(dir), length);
function polaradd(origin, dir, length) =
[origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
function fromcompass(a) = normalize_angle(90+360-a);
// Normalize an angle so that it is between 0..360
function normalize_angle(a) = (a%360 + 360)%360;
so if I was describing the path you described above, it would end up
something like:
p1 = [0,0];
p2 = vector(p1, 90, 500);
p3 = vector(p2, 0, 30);
p4 = vector(p3, 90, 70.5);
p5 = vector(p4, 90, 80);
That's a very verbose representation, but (a) the typing was only a very
small fraction of the cost, and (b) it allowed me to base multiple
"next" points on a single point. That is, if I needed to *also* go west
from point 3, that was straightforward. I can provide additional
details on how I represented walls if you like.
But going back to your question...
* Converting a string like "e500, n30, e70.5, e80" into something more
directly usable, like a list of compass bearings and distances.
I would do this in preprocessing, rather than trying to do it in
OpenSCAD per se. You certainly *can* do such things in OpenSCAD, but it
is no fun at all.I would use an editor (vi, sed, et cetera) or maybe a
text-friendly programming language to add in the brackets and turn
"eNNN" to "90, NNN".
* Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
cartesian_relative = [ for (p=polar_relative) p[1] * [cos(p[0]), sin(p[0])] ];
* Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
This is a variation on the classic "running sum" problem, which is never
any fun. (But not quite common enough or un-fun enough for me to have a
stock solution anywhere.)
Here's *a* solution, though I'm not entirely happy with it. I think it
can be optimized a bit but don't have the energy right now:
function runningSum(a, i=0) =
[
a[0],
for ( i = 0, t = a[0]; i+1 < len(a); i=i+1, t=t+a[i]) t + a[i]
];
Notes:
* I didn't want to have it know what type the array is - it should
be anything that you can add: numbers, vec2s, vec3s, et cetera.
* It needs to emit the last entry *without* stepping past the end
of the array.
AM
Adrian Mariano
Mon, Jun 24, 2024 8:33 PM
Parsing the list isn't that hard with BOSL2:
include <BOSL2/std.scad>
data = [for (entry = str_split("e500, n30, e70.5, e80", ", ",
keep_nulls=false))
[entry[0], parse_num(substr(entry,1))]];
echo(data);
produces:
[["e", 500], ["n", 30], ["e", 70.5], ["e", 80]]
On Mon, Jun 24, 2024 at 4:21 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 6/24/2024 12:37 PM, Raymond West via Discuss wrote:
Hi, I've been measuring some buildings, by walking around the sides with a
tape measure. I've recorded the measurements in a notebook, with a rough
outline. The easiest way I can think of is entering the data is as a comma
separated string, something like "e500, n30,e70.5, e80", etc. where the
letters signify direction, east, west, north, south (assuming building is
square, but maybe it needs a rethink, with just a compass bearing in
degrees, say, instead of the letters - would be useful for bay windows,
etc.) However, in order to get an external floor plan, I need it to be
converted to a list of vectors - in the above example it would be
[[500,0],[530,30],[570.5,30],[650.5,30]] (If I've added it up correctly).
However, I'm struggling to do that within openscad.
The number of measurements involved, makes it tedious to enter the list
syntax directly. Any ideas on how to do the conversion within openscad? I
want to minimise the keystrokes for data entry.
For a non-DIY solution, consider BOSL2's turtle-graphics function:
https://github.com/BelfrySCAD/BOSL2/wiki/drawing.scad#function-turtle
ISTM that there are approximately three steps to the problem you're
describing.
- Converting a string like "e500, n30, e70.5, e80" into something more
directly usable, like a list of compass bearings and distances.
- Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
- Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
For my own house model, my biggest tool was my "vector" function:
function vector(origin, dir, length) = polaradd(origin, fromcompass(dir), length);
function polaradd(origin, dir, length) =
[origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
function fromcompass(a) = normalize_angle(90+360-a);
// Normalize an angle so that it is between 0..360
function normalize_angle(a) = (a%360 + 360)%360;
so if I was describing the path you described above, it would end up
something like:
p1 = [0,0];
p2 = vector(p1, 90, 500);
p3 = vector(p2, 0, 30);
p4 = vector(p3, 90, 70.5);
p5 = vector(p4, 90, 80);
That's a very verbose representation, but (a) the typing was only a very
small fraction of the cost, and (b) it allowed me to base multiple "next"
points on a single point. That is, if I needed to also go west from
point 3, that was straightforward. I can provide additional details on how
I represented walls if you like.
But going back to your question...
- Converting a string like "e500, n30, e70.5, e80" into something more
directly usable, like a list of compass bearings and distances.
I would do this in preprocessing, rather than trying to do it in OpenSCAD
per se. You certainly can do such things in OpenSCAD, but it is no fun
at all.I would use an editor (vi, sed, et cetera) or maybe a text-friendly
programming language to add in the brackets and turn "eNNN" to "90, NNN".
- Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
cartesian_relative = [ for (p=polar_relative) p[1] * [cos(p[0]), sin(p[0])] ];
- Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
This is a variation on the classic "running sum" problem, which is never
any fun. (But not quite common enough or un-fun enough for me to have a
stock solution anywhere.)
Here's a solution, though I'm not entirely happy with it. I think it
can be optimized a bit but don't have the energy right now:
function runningSum(a, i=0) =
[
a[0],
for ( i = 0, t = a[0]; i+1 < len(a); i=i+1, t=t+a[i]) t + a[i]
];
Notes:
- I didn't want to have it know what type the array is - it should be
anything that you can add: numbers, vec2s, vec3s, et cetera.
- It needs to emit the last entry *without* stepping past the end of
the array.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Parsing the list isn't that hard with BOSL2:
include <BOSL2/std.scad>
data = [for (entry = str_split("e500, n30, e70.5, e80", ", ",
keep_nulls=false))
[entry[0], parse_num(substr(entry,1))]];
echo(data);
produces:
[["e", 500], ["n", 30], ["e", 70.5], ["e", 80]]
On Mon, Jun 24, 2024 at 4:21 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
> On 6/24/2024 12:37 PM, Raymond West via Discuss wrote:
>
> Hi, I've been measuring some buildings, by walking around the sides with a
> tape measure. I've recorded the measurements in a notebook, with a rough
> outline. The easiest way I can think of is entering the data is as a comma
> separated string, something like "e500, n30,e70.5, e80", etc. where the
> letters signify direction, east, west, north, south (assuming building is
> square, but maybe it needs a rethink, with just a compass bearing in
> degrees, say, instead of the letters - would be useful for bay windows,
> etc.) However, in order to get an external floor plan, I need it to be
> converted to a list of vectors - in the above example it would be
> [[500,0],[530,30],[570.5,30],[650.5,30]] (If I've added it up correctly).
> However, I'm struggling to do that within openscad.
>
> The number of measurements involved, makes it tedious to enter the list
> syntax directly. Any ideas on how to do the conversion within openscad? I
> want to minimise the keystrokes for data entry.
>
>
> For a non-DIY solution, consider BOSL2's turtle-graphics function:
> https://github.com/BelfrySCAD/BOSL2/wiki/drawing.scad#function-turtle
>
> ISTM that there are approximately three steps to the problem you're
> describing.
>
> - Converting a string like "e500, n30, e70.5, e80" into something more
> directly usable, like a list of compass bearings and distances.
> - Converting a list of compass bearings and distances into a list of
> Cartesian relative positions.
> - Converting a list of Cartesian relative positions into a list of
> Cartesian absolute positions.
>
> For my own house model, my biggest tool was my "vector" function:
>
> function vector(origin, dir, length) = polaradd(origin, fromcompass(dir), length);
> function polaradd(origin, dir, length) =
> [origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
> function fromcompass(a) = normalize_angle(90+360-a);
> // Normalize an angle so that it is between 0..360
> function normalize_angle(a) = (a%360 + 360)%360;
>
> so if I was describing the path you described above, it would end up
> something like:
>
> p1 = [0,0];
> p2 = vector(p1, 90, 500);
> p3 = vector(p2, 0, 30);
> p4 = vector(p3, 90, 70.5);
> p5 = vector(p4, 90, 80);
>
> That's a very verbose representation, but (a) the typing was only a very
> small fraction of the cost, and (b) it allowed me to base multiple "next"
> points on a single point. That is, if I needed to *also* go west from
> point 3, that was straightforward. I can provide additional details on how
> I represented walls if you like.
>
> But going back to your question...
>
> - Converting a string like "e500, n30, e70.5, e80" into something more
> directly usable, like a list of compass bearings and distances.
>
> I would do this in preprocessing, rather than trying to do it in OpenSCAD
> per se. You certainly *can* do such things in OpenSCAD, but it is no fun
> at all.I would use an editor (vi, sed, et cetera) or maybe a text-friendly
> programming language to add in the brackets and turn "eNNN" to "90, NNN".
>
> - Converting a list of compass bearings and distances into a list of
> Cartesian relative positions.
>
> cartesian_relative = [ for (p=polar_relative) p[1] * [cos(p[0]), sin(p[0])] ];
>
>
> - Converting a list of Cartesian relative positions into a list of
> Cartesian absolute positions.
>
> This is a variation on the classic "running sum" problem, which is never
> any fun. (But not quite common enough or un-fun enough for me to have a
> stock solution anywhere.)
>
> Here's *a* solution, though I'm not entirely happy with it. I think it
> can be optimized a bit but don't have the energy right now:
>
> function runningSum(a, i=0) =
> [
> a[0],
> for ( i = 0, t = a[0]; i+1 < len(a); i=i+1, t=t+a[i]) t + a[i]
> ];
>
> Notes:
>
>
> - I didn't want to have it know what type the array is - it should be
> anything that you can add: numbers, vec2s, vec3s, et cetera.
> - It needs to emit the last entry *without* stepping past the end of
> the array.
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
DM
Daniel Miner
Mon, Jun 24, 2024 8:46 PM
I can't help but wonder how many sides does this building have such that
the time spent researching this will be less than the time to just type out
the long version. :)
On Mon, Jun 24, 2024 at 3:33 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Parsing the list isn't that hard with BOSL2:
include <BOSL2/std.scad>
data = [for (entry = str_split("e500, n30, e70.5, e80", ", ",
keep_nulls=false))
[entry[0], parse_num(substr(entry,1))]];
echo(data);
produces:
[["e", 500], ["n", 30], ["e", 70.5], ["e", 80]]
On Mon, Jun 24, 2024 at 4:21 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 6/24/2024 12:37 PM, Raymond West via Discuss wrote:
Hi, I've been measuring some buildings, by walking around the sides with
a tape measure. I've recorded the measurements in a notebook, with a rough
outline. The easiest way I can think of is entering the data is as a comma
separated string, something like "e500, n30,e70.5, e80", etc. where the
letters signify direction, east, west, north, south (assuming building is
square, but maybe it needs a rethink, with just a compass bearing in
degrees, say, instead of the letters - would be useful for bay windows,
etc.) However, in order to get an external floor plan, I need it to be
converted to a list of vectors - in the above example it would be
[[500,0],[530,30],[570.5,30],[650.5,30]] (If I've added it up correctly).
However, I'm struggling to do that within openscad.
The number of measurements involved, makes it tedious to enter the list
syntax directly. Any ideas on how to do the conversion within openscad? I
want to minimise the keystrokes for data entry.
For a non-DIY solution, consider BOSL2's turtle-graphics function:
https://github.com/BelfrySCAD/BOSL2/wiki/drawing.scad#function-turtle
ISTM that there are approximately three steps to the problem you're
describing.
- Converting a string like "e500, n30, e70.5, e80" into something
more directly usable, like a list of compass bearings and distances.
- Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
- Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
For my own house model, my biggest tool was my "vector" function:
function vector(origin, dir, length) = polaradd(origin, fromcompass(dir), length);
function polaradd(origin, dir, length) =
[origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
function fromcompass(a) = normalize_angle(90+360-a);
// Normalize an angle so that it is between 0..360
function normalize_angle(a) = (a%360 + 360)%360;
so if I was describing the path you described above, it would end up
something like:
p1 = [0,0];
p2 = vector(p1, 90, 500);
p3 = vector(p2, 0, 30);
p4 = vector(p3, 90, 70.5);
p5 = vector(p4, 90, 80);
That's a very verbose representation, but (a) the typing was only a very
small fraction of the cost, and (b) it allowed me to base multiple "next"
points on a single point. That is, if I needed to also go west from
point 3, that was straightforward. I can provide additional details on how
I represented walls if you like.
But going back to your question...
- Converting a string like "e500, n30, e70.5, e80" into something
more directly usable, like a list of compass bearings and distances.
I would do this in preprocessing, rather than trying to do it in OpenSCAD
per se. You certainly can do such things in OpenSCAD, but it is no fun
at all.I would use an editor (vi, sed, et cetera) or maybe a text-friendly
programming language to add in the brackets and turn "eNNN" to "90, NNN".
- Converting a list of compass bearings and distances into a list of
Cartesian relative positions.
cartesian_relative = [ for (p=polar_relative) p[1] * [cos(p[0]), sin(p[0])] ];
- Converting a list of Cartesian relative positions into a list of
Cartesian absolute positions.
This is a variation on the classic "running sum" problem, which is never
any fun. (But not quite common enough or un-fun enough for me to have a
stock solution anywhere.)
Here's a solution, though I'm not entirely happy with it. I think it
can be optimized a bit but don't have the energy right now:
function runningSum(a, i=0) =
[
a[0],
for ( i = 0, t = a[0]; i+1 < len(a); i=i+1, t=t+a[i]) t + a[i]
];
Notes:
- I didn't want to have it know what type the array is - it should be
anything that you can add: numbers, vec2s, vec3s, et cetera.
- It needs to emit the last entry *without* stepping past the end of
the array.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I can't help but wonder how many sides does this building have such that
the time spent researching this will be less than the time to just type out
the long version. :)
On Mon, Jun 24, 2024 at 3:33 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
> Parsing the list isn't that hard with BOSL2:
>
> include <BOSL2/std.scad>
>
> data = [for (entry = str_split("e500, n30, e70.5, e80", ", ",
> keep_nulls=false))
> [entry[0], parse_num(substr(entry,1))]];
> echo(data);
>
> produces:
>
> [["e", 500], ["n", 30], ["e", 70.5], ["e", 80]]
>
>
>
> On Mon, Jun 24, 2024 at 4:21 PM Jordan Brown via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> On 6/24/2024 12:37 PM, Raymond West via Discuss wrote:
>>
>> Hi, I've been measuring some buildings, by walking around the sides with
>> a tape measure. I've recorded the measurements in a notebook, with a rough
>> outline. The easiest way I can think of is entering the data is as a comma
>> separated string, something like "e500, n30,e70.5, e80", etc. where the
>> letters signify direction, east, west, north, south (assuming building is
>> square, but maybe it needs a rethink, with just a compass bearing in
>> degrees, say, instead of the letters - would be useful for bay windows,
>> etc.) However, in order to get an external floor plan, I need it to be
>> converted to a list of vectors - in the above example it would be
>> [[500,0],[530,30],[570.5,30],[650.5,30]] (If I've added it up correctly).
>> However, I'm struggling to do that within openscad.
>>
>> The number of measurements involved, makes it tedious to enter the list
>> syntax directly. Any ideas on how to do the conversion within openscad? I
>> want to minimise the keystrokes for data entry.
>>
>>
>> For a non-DIY solution, consider BOSL2's turtle-graphics function:
>> https://github.com/BelfrySCAD/BOSL2/wiki/drawing.scad#function-turtle
>>
>> ISTM that there are approximately three steps to the problem you're
>> describing.
>>
>> - Converting a string like "e500, n30, e70.5, e80" into something
>> more directly usable, like a list of compass bearings and distances.
>> - Converting a list of compass bearings and distances into a list of
>> Cartesian relative positions.
>> - Converting a list of Cartesian relative positions into a list of
>> Cartesian absolute positions.
>>
>> For my own house model, my biggest tool was my "vector" function:
>>
>> function vector(origin, dir, length) = polaradd(origin, fromcompass(dir), length);
>> function polaradd(origin, dir, length) =
>> [origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
>> function fromcompass(a) = normalize_angle(90+360-a);
>> // Normalize an angle so that it is between 0..360
>> function normalize_angle(a) = (a%360 + 360)%360;
>>
>> so if I was describing the path you described above, it would end up
>> something like:
>>
>> p1 = [0,0];
>> p2 = vector(p1, 90, 500);
>> p3 = vector(p2, 0, 30);
>> p4 = vector(p3, 90, 70.5);
>> p5 = vector(p4, 90, 80);
>>
>> That's a very verbose representation, but (a) the typing was only a very
>> small fraction of the cost, and (b) it allowed me to base multiple "next"
>> points on a single point. That is, if I needed to *also* go west from
>> point 3, that was straightforward. I can provide additional details on how
>> I represented walls if you like.
>>
>> But going back to your question...
>>
>> - Converting a string like "e500, n30, e70.5, e80" into something
>> more directly usable, like a list of compass bearings and distances.
>>
>> I would do this in preprocessing, rather than trying to do it in OpenSCAD
>> per se. You certainly *can* do such things in OpenSCAD, but it is no fun
>> at all.I would use an editor (vi, sed, et cetera) or maybe a text-friendly
>> programming language to add in the brackets and turn "eNNN" to "90, NNN".
>>
>> - Converting a list of compass bearings and distances into a list of
>> Cartesian relative positions.
>>
>> cartesian_relative = [ for (p=polar_relative) p[1] * [cos(p[0]), sin(p[0])] ];
>>
>>
>> - Converting a list of Cartesian relative positions into a list of
>> Cartesian absolute positions.
>>
>> This is a variation on the classic "running sum" problem, which is never
>> any fun. (But not quite common enough or un-fun enough for me to have a
>> stock solution anywhere.)
>>
>> Here's *a* solution, though I'm not entirely happy with it. I think it
>> can be optimized a bit but don't have the energy right now:
>>
>> function runningSum(a, i=0) =
>> [
>> a[0],
>> for ( i = 0, t = a[0]; i+1 < len(a); i=i+1, t=t+a[i]) t + a[i]
>> ];
>>
>> Notes:
>>
>>
>> - I didn't want to have it know what type the array is - it should be
>> anything that you can add: numbers, vec2s, vec3s, et cetera.
>> - It needs to emit the last entry *without* stepping past the end of
>> the array.
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
JB
Jordan Brown
Tue, Jun 25, 2024 2:32 AM
On 6/24/2024 1:46 PM, Daniel Miner via Discuss wrote:
I can't help but wonder how many sides does this building have such
that the time spent researching this will be less than the time to
just type out the long version. :)
Indeed, and as I said for my house I didn't bother trying to optimize
the representation because that wasn't the hard part.
But I have about 155 walls and just under 250 calls to "vector".
On 6/24/2024 1:46 PM, Daniel Miner via Discuss wrote:
> I can't help but wonder how many sides does this building have such
> that the time spent researching this will be less than the time to
> just type out the long version. :)
Indeed, and as I said for my house I didn't bother trying to optimize
the representation because that wasn't the hard part.
But I have about 155 walls and just under 250 calls to "vector".
RW
Raymond West
Tue, Jun 25, 2024 11:41 AM
Thanks for all your replies. I've decided to go with Steve'sidea "A
quick and lazy way that I think would work" which at the moment suits me
fine, except the summing of the elements is going to need a recursive
function, at least, which tends to bother me. If I'm happy with it, I'll
post the code.
So far, excluding windows and doors, for the exterior of the building,
there are about 60 points to play with, but later, once the proof of
concept is completed, I will probably persuade ChatGPT to write some
python code, or something, to simplify all the data entry. ChatGPT is OK
at Python, at least for my purposes, but not so good with openscad,
where it becomes a battle of wills.
Best wishes,
Ray
Thanks for all your replies. I've decided to go with Steve'sidea "A
quick and lazy way that I think would work" which at the moment suits me
fine, except the summing of the elements is going to need a recursive
function, at least, which tends to bother me. If I'm happy with it, I'll
post the code.
So far, excluding windows and doors, for the exterior of the building,
there are about 60 points to play with, but later, once the proof of
concept is completed, I will probably persuade ChatGPT to write some
python code, or something, to simplify all the data entry. ChatGPT is OK
at Python, at least for my purposes, but not so good with openscad,
where it becomes a battle of wills.
Best wishes,
Ray
RW
Raymond West
Tue, Jun 25, 2024 12:45 PM
Here's the code, for the north facing wall, and a bit of the two sides.
Thanks for the help. (and ChatGPT, who got there in the end)
// points from wall distances
n=[0,1];s=[0,-1];e=[1,0];w=[-1,0];
p=
[e0,w8.5,s38,w5,w95,w110,w50,w4,n37,w75,n7,w44,s8,w52,w62,w70,w39,w69,w43,s90,e*726.5];
function build_new_list(p, new = [[0, 0]]) =
len(new) > len(p) ? new :
let (last = new[len(new) - 1],
next = [last[0] + p[len(new) - 1][0], last[1] + p[len(new) -
1][1]])
build_new_list(p, concat(new, [next]));
new = build_new_list(p);
echo(old=p);
echo(new=new);
polygon(new);
////////////////////////////////////////////////////
On 25/06/2024 12:41, Raymond West via Discuss wrote:
Thanks for all your replies. I've decided to go with Steve'sidea "A
quick and lazy way that I think would work" which at the moment suits
me fine, except the summing of the elements is going to need a
recursive function, at least, which tends to bother me. If I'm happy
with it, I'll post the code.
So far, excluding windows and doors, for the exterior of the building,
there are about 60 points to play with, but later, once the proof of
concept is completed, I will probably persuade ChatGPT to write some
python code, or something, to simplify all the data entry. ChatGPT is
OK at Python, at least for my purposes, but not so good with openscad,
where it becomes a battle of wills.
Best wishes,
Ray
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
Here's the code, for the north facing wall, and a bit of the two sides.
Thanks for the help. (and ChatGPT, who got there in the end)
// points from wall distances
n=[0,1];s=[0,-1];e=[1,0];w=[-1,0];
p=
[e*0,w*8.5,s*38,w*5,w*95,w*110,w*50,w*4,n*37,w*75,n*7,w*44,s*8,w*52,w*62,w*70,w*39,w*69,w*43,s*90,e*726.5];
function build_new_list(p, new = [[0, 0]]) =
len(new) > len(p) ? new :
let (last = new[len(new) - 1],
next = [last[0] + p[len(new) - 1][0], last[1] + p[len(new) -
1][1]])
build_new_list(p, concat(new, [next]));
new = build_new_list(p);
echo(old=p);
echo(new=new);
polygon(new);
////////////////////////////////////////////////////
On 25/06/2024 12:41, Raymond West via Discuss wrote:
>
> Thanks for all your replies. I've decided to go with Steve'sidea "A
> quick and lazy way that I think would work" which at the moment suits
> me fine, except the summing of the elements is going to need a
> recursive function, at least, which tends to bother me. If I'm happy
> with it, I'll post the code.
>
> So far, excluding windows and doors, for the exterior of the building,
> there are about 60 points to play with, but later, once the proof of
> concept is completed, I will probably persuade ChatGPT to write some
> python code, or something, to simplify all the data entry. ChatGPT is
> OK at Python, at least for my purposes, but not so good with openscad,
> where it becomes a battle of wills.
>
> Best wishes,
>
> Ray
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org
SP
Sanjeev Prabhakar
Tue, Jun 25, 2024 2:29 PM
There is a pathbuilder library with similar applications I think.
It's interesting, I tried it long back
On Tue, 25 Jun 2024 at 18:16, Raymond West via Discuss <
discuss@lists.openscad.org> wrote:
Here's the code, for the north facing wall, and a bit of the two sides.
Thanks for the help. (and ChatGPT, who got there in the end)
// points from wall distances
n=[0,1];s=[0,-1];e=[1,0];w=[-1,0];
p=
[e0,w8.5,s38,w5,w95,w110,w50,w4,n37,w75,n7,w44,s8,w52,w62,w70,w39,w69,w43,s90,e*726.5];
function build_new_list(p, new = [[0, 0]]) =
len(new) > len(p) ? new :
let (last = new[len(new) - 1],
next = [last[0] + p[len(new) - 1][0], last[1] + p[len(new) -
1][1]])
build_new_list(p, concat(new, [next]));
new = build_new_list(p);
echo(old=p);
echo(new=new);
polygon(new);
////////////////////////////////////////////////////
On 25/06/2024 12:41, Raymond West via Discuss wrote:
Thanks for all your replies. I've decided to go with Steve's idea "A
quick and lazy way that I think would work" which at the moment suits me
fine, except the summing of the elements is going to need a recursive
function, at least, which tends to bother me. If I'm happy with it, I'll
post the code.
So far, excluding windows and doors, for the exterior of the building,
there are about 60 points to play with, but later, once the proof of
concept is completed, I will probably persuade ChatGPT to write some python
code, or something, to simplify all the data entry. ChatGPT is OK at
Python, at least for my purposes, but not so good with openscad, where it
becomes a battle of wills.
Best wishes,
Ray
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
There is a pathbuilder library with similar applications I think.
It's interesting, I tried it long back
On Tue, 25 Jun 2024 at 18:16, Raymond West via Discuss <
discuss@lists.openscad.org> wrote:
> Here's the code, for the north facing wall, and a bit of the two sides.
> Thanks for the help. (and ChatGPT, who got there in the end)
>
>
> // points from wall distances
> n=[0,1];s=[0,-1];e=[1,0];w=[-1,0];
> p=
> [e*0,w*8.5,s*38,w*5,w*95,w*110,w*50,w*4,n*37,w*75,n*7,w*44,s*8,w*52,w*62,w*70,w*39,w*69,w*43,s*90,e*726.5];
>
> function build_new_list(p, new = [[0, 0]]) =
> len(new) > len(p) ? new :
> let (last = new[len(new) - 1],
> next = [last[0] + p[len(new) - 1][0], last[1] + p[len(new) -
> 1][1]])
> build_new_list(p, concat(new, [next]));
>
>
> new = build_new_list(p);
> echo(old=p);
> echo(new=new);
>
> polygon(new);
> ////////////////////////////////////////////////////
> On 25/06/2024 12:41, Raymond West via Discuss wrote:
>
> Thanks for all your replies. I've decided to go with Steve's idea "A
> quick and lazy way that I think would work" which at the moment suits me
> fine, except the summing of the elements is going to need a recursive
> function, at least, which tends to bother me. If I'm happy with it, I'll
> post the code.
>
> So far, excluding windows and doors, for the exterior of the building,
> there are about 60 points to play with, but later, once the proof of
> concept is completed, I will probably persuade ChatGPT to write some python
> code, or something, to simplify all the data entry. ChatGPT is OK at
> Python, at least for my purposes, but not so good with openscad, where it
> becomes a battle of wills.
>
> Best wishes,
>
> Ray
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>