discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Span an area between 3 points

A
arnholm@arnholm.org
Sat, Oct 31, 2020 1:04 PM

On 2020-10-31 13:58, nop head wrote:

So what is your solution to construct a transform to rotate and shear
a plane to align with an arbitrary parallelogram?

The problem was presented with this illustration
http://forum.openscad.org/file/t2988/span-area.jpg

As far as I can tell you can do exactly what the figure indicates, add
the vector d to each point to arrive at the parallelogram. But maybe I
am missing something?

Carsten Arnholm

On 2020-10-31 13:58, nop head wrote: > So what is your solution to construct a transform to rotate and shear > a plane to align with an arbitrary parallelogram? The problem was presented with this illustration http://forum.openscad.org/file/t2988/span-area.jpg As far as I can tell you can do exactly what the figure indicates, add the vector d to each point to arrive at the parallelogram. But maybe I am missing something? Carsten Arnholm
NH
nop head
Sat, Oct 31, 2020 1:10 PM

Yes it would be easy to calculate the forth vector to complete the polygon
but then how do you draw it with text, which are 2D operations operating in
the XY plane?

On Sat, 31 Oct 2020 at 13:05, arnholm@arnholm.org wrote:

On 2020-10-31 13:58, nop head wrote:

So what is your solution to construct a transform to rotate and shear
a plane to align with an arbitrary parallelogram?

The problem was presented with this illustration
http://forum.openscad.org/file/t2988/span-area.jpg

As far as I can tell you can do exactly what the figure indicates, add
the vector d to each point to arrive at the parallelogram. But maybe I
am missing something?

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes it would be easy to calculate the forth vector to complete the polygon but then how do you draw it with text, which are 2D operations operating in the XY plane? On Sat, 31 Oct 2020 at 13:05, <arnholm@arnholm.org> wrote: > On 2020-10-31 13:58, nop head wrote: > > So what is your solution to construct a transform to rotate and shear > > a plane to align with an arbitrary parallelogram? > > The problem was presented with this illustration > http://forum.openscad.org/file/t2988/span-area.jpg > > As far as I can tell you can do exactly what the figure indicates, add > the vector d to each point to arrive at the parallelogram. But maybe I > am missing something? > > Carsten Arnholm > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
arnholm@arnholm.org
Sat, Oct 31, 2020 1:22 PM

On 2020-10-31 14:10, nop head wrote:

Yes it would be easy to calculate the forth vector to complete the
polygon but then how do you draw it with text, which are 2D operations
operating in the XY plane?

I have not studied the details, but obviously you can compute the plane
equation from 3 points.  Or even simpler, create a vector from P1 to P2
and compute a couple of cross products (the first with vector d) to
arrive at the 3 first columns of the transformation matrix. The fourth
is simply choosing an origin. So I thing you can transform the text with
the resulting matrix.

Carsten Arnholm

On 2020-10-31 14:10, nop head wrote: > Yes it would be easy to calculate the forth vector to complete the > polygon but then how do you draw it with text, which are 2D operations > operating in the XY plane? I have not studied the details, but obviously you can compute the plane equation from 3 points. Or even simpler, create a vector from P1 to P2 and compute a couple of cross products (the first with vector d) to arrive at the 3 first columns of the transformation matrix. The fourth is simply choosing an origin. So I thing you can transform the text with the resulting matrix. Carsten Arnholm
NH
nop head
Sat, Oct 31, 2020 1:37 PM

That is pretty much exactly what I did.

On Sat, 31 Oct 2020 at 13:22, arnholm@arnholm.org wrote:

On 2020-10-31 14:10, nop head wrote:

Yes it would be easy to calculate the forth vector to complete the
polygon but then how do you draw it with text, which are 2D operations
operating in the XY plane?

I have not studied the details, but obviously you can compute the plane
equation from 3 points.  Or even simpler, create a vector from P1 to P2
and compute a couple of cross products (the first with vector d) to
arrive at the 3 first columns of the transformation matrix. The fourth
is simply choosing an origin. So I thing you can transform the text with
the resulting matrix.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

That is pretty much exactly what I did. On Sat, 31 Oct 2020 at 13:22, <arnholm@arnholm.org> wrote: > On 2020-10-31 14:10, nop head wrote: > > Yes it would be easy to calculate the forth vector to complete the > > polygon but then how do you draw it with text, which are 2D operations > > operating in the XY plane? > > I have not studied the details, but obviously you can compute the plane > equation from 3 points. Or even simpler, create a vector from P1 to P2 > and compute a couple of cross products (the first with vector d) to > arrive at the 3 first columns of the transformation matrix. The fourth > is simply choosing an origin. So I thing you can transform the text with > the resulting matrix. > > Carsten Arnholm > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Sun, Nov 1, 2020 9:15 AM

Here is a simpler version. Instead of computing the shear and applying it I
simply set up the X and Y axes along the edges of the parallelogram and
make Z orthogonal to both with a cross product.

module fill(p1,p2,d)
{
// this is the vector
v=p2-p1;

// length of vector
l=norm(v);

// length of d
h=norm(d);

x = unit(v);
y = unit(d);
z = unit(cross(v, d));
m = [[x.x, y.x, z.x, p1.x],
     [x.y, y.y, z.y, p1.y],
     [x.z, y.z, z.z, p1.z],
     [0,   0,   0,   1   ]];

multmatrix(m) area(l,h,"p1","p2","p1+d","p2+d");

}

On Sat, 31 Oct 2020 at 13:37, nop head nop.head@gmail.com wrote:

That is pretty much exactly what I did.

On Sat, 31 Oct 2020 at 13:22, arnholm@arnholm.org wrote:

On 2020-10-31 14:10, nop head wrote:

Yes it would be easy to calculate the forth vector to complete the
polygon but then how do you draw it with text, which are 2D operations
operating in the XY plane?

I have not studied the details, but obviously you can compute the plane
equation from 3 points.  Or even simpler, create a vector from P1 to P2
and compute a couple of cross products (the first with vector d) to
arrive at the 3 first columns of the transformation matrix. The fourth
is simply choosing an origin. So I thing you can transform the text with
the resulting matrix.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Here is a simpler version. Instead of computing the shear and applying it I simply set up the X and Y axes along the edges of the parallelogram and make Z orthogonal to both with a cross product. module fill(p1,p2,d) { // this is the vector v=p2-p1; // length of vector l=norm(v); // length of d h=norm(d); x = unit(v); y = unit(d); z = unit(cross(v, d)); m = [[x.x, y.x, z.x, p1.x], [x.y, y.y, z.y, p1.y], [x.z, y.z, z.z, p1.z], [0, 0, 0, 1 ]]; multmatrix(m) area(l,h,"p1","p2","p1+d","p2+d"); } On Sat, 31 Oct 2020 at 13:37, nop head <nop.head@gmail.com> wrote: > That is pretty much exactly what I did. > > On Sat, 31 Oct 2020 at 13:22, <arnholm@arnholm.org> wrote: > >> On 2020-10-31 14:10, nop head wrote: >> > Yes it would be easy to calculate the forth vector to complete the >> > polygon but then how do you draw it with text, which are 2D operations >> > operating in the XY plane? >> >> I have not studied the details, but obviously you can compute the plane >> equation from 3 points. Or even simpler, create a vector from P1 to P2 >> and compute a couple of cross products (the first with vector d) to >> arrive at the 3 first columns of the transformation matrix. The fourth >> is simply choosing an origin. So I thing you can transform the text with >> the resulting matrix. >> >> Carsten Arnholm >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
A
arnholm@arnholm.org
Sun, Nov 1, 2020 9:45 AM

On 2020-11-01 10:15, nop head wrote:

Here is a simpler version. Instead of computing the shear and applying
it I simply set up the X and Y axes along the edges of the
parallelogram and make Z orthogonal to both with a cross product.

module fill(p1,p2,d)
{
// this is the vector
v=p2-p1;

 // length of vector
 l=norm(v);

 // length of d
 h=norm(d);

 x = unit(v);
 y = unit(d);
 z = unit(cross(v, d));
 m = [[x.x, y.x, z.x, p1.x],
      [x.y, y.y, z.y, p1.y],
      [x.z, y.z, z.z, p1.z],
      [0,   0,   0,   1   ]];

 multmatrix(m) area(l,h,"p1","p2","p1+d","p2+d");

}

That's pretty much it, except with this you are assuming it is a
rectangle, not a parallelogram. In the above, d is typically not
orthogonal to v, so the matrix m is then incorrect. That's why I said "a
couple of cross products" and not just one as in your code. If you cross
z with x you can arrive at a new y and thus arrive at an orthogonal m.

Carsten Arholm

On 2020-11-01 10:15, nop head wrote: > Here is a simpler version. Instead of computing the shear and applying > it I simply set up the X and Y axes along the edges of the > parallelogram and make Z orthogonal to both with a cross product. > > module fill(p1,p2,d) > { > // this is the vector > v=p2-p1; > > // length of vector > l=norm(v); > > // length of d > h=norm(d); > > x = unit(v); > y = unit(d); > z = unit(cross(v, d)); > m = [[x.x, y.x, z.x, p1.x], > [x.y, y.y, z.y, p1.y], > [x.z, y.z, z.z, p1.z], > [0, 0, 0, 1 ]]; > > multmatrix(m) area(l,h,"p1","p2","p1+d","p2+d"); > } That's pretty much it, except with this you are assuming it is a rectangle, not a parallelogram. In the above, d is typically not orthogonal to v, so the matrix m is then incorrect. That's why I said "a couple of cross products" and not just one as in your code. If you cross z with x you can arrive at a new y and thus arrive at an orthogonal m. Carsten Arholm
NH
nop head
Sun, Nov 1, 2020 10:01 AM

My previous iteration had two cross products so that the new axes were
mutually orthogonal because I thought that was a requirement. But it seems
not as aligning the axes with the parallelogram works to skew the rectangle
to map onto it. Presumably the matrix values are identical to the version
with orthogonal axes post multiplied by the skew matrix. The end result
looks the same.

On Sun, 1 Nov 2020 at 09:46, arnholm@arnholm.org wrote:

On 2020-11-01 10:15, nop head wrote:

Here is a simpler version. Instead of computing the shear and applying
it I simply set up the X and Y axes along the edges of the
parallelogram and make Z orthogonal to both with a cross product.

module fill(p1,p2,d)
{
// this is the vector
v=p2-p1;

 // length of vector
 l=norm(v);

 // length of d
 h=norm(d);

 x = unit(v);
 y = unit(d);
 z = unit(cross(v, d));
 m = [[x.x, y.x, z.x, p1.x],
      [x.y, y.y, z.y, p1.y],
      [x.z, y.z, z.z, p1.z],
      [0,   0,   0,   1   ]];

 multmatrix(m) area(l,h,"p1","p2","p1+d","p2+d");

}

That's pretty much it, except with this you are assuming it is a
rectangle, not a parallelogram. In the above, d is typically not
orthogonal to v, so the matrix m is then incorrect. That's why I said "a
couple of cross products" and not just one as in your code. If you cross
z with x you can arrive at a new y and thus arrive at an orthogonal m.

Carsten Arholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

My previous iteration had two cross products so that the new axes were mutually orthogonal because I thought that was a requirement. But it seems not as aligning the axes with the parallelogram works to skew the rectangle to map onto it. Presumably the matrix values are identical to the version with orthogonal axes post multiplied by the skew matrix. The end result looks the same. On Sun, 1 Nov 2020 at 09:46, <arnholm@arnholm.org> wrote: > On 2020-11-01 10:15, nop head wrote: > > Here is a simpler version. Instead of computing the shear and applying > > it I simply set up the X and Y axes along the edges of the > > parallelogram and make Z orthogonal to both with a cross product. > > > > module fill(p1,p2,d) > > { > > // this is the vector > > v=p2-p1; > > > > // length of vector > > l=norm(v); > > > > // length of d > > h=norm(d); > > > > x = unit(v); > > y = unit(d); > > z = unit(cross(v, d)); > > m = [[x.x, y.x, z.x, p1.x], > > [x.y, y.y, z.y, p1.y], > > [x.z, y.z, z.z, p1.z], > > [0, 0, 0, 1 ]]; > > > > multmatrix(m) area(l,h,"p1","p2","p1+d","p2+d"); > > } > > > That's pretty much it, except with this you are assuming it is a > rectangle, not a parallelogram. In the above, d is typically not > orthogonal to v, so the matrix m is then incorrect. That's why I said "a > couple of cross products" and not just one as in your code. If you cross > z with x you can arrive at a new y and thus arrive at an orthogonal m. > > Carsten Arholm > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >