I have reduced my problem (see
Trouble-with-rotating-Text-to-correct-orientation
http://forum.openscad.org/Trouble-with-rotating-Text-to-correct-orientation-td30280.html
) to one rotating angel, I cannot find the correct calculation.
The task is to span an area between two points P1 and P2 in a direction
given by a direction vector D (which is identical to the problem in the
subject).
The image illustrates it:
http://forum.openscad.org/file/t2988/span-area.jpg
If you load the attached script ( span-area.scad
http://forum.openscad.org/file/t2988/span-area.scad ) into OpenSCAD and
open the Customizer, you can move P1 and P2 anywhere and the grey fill area
is placed perfect. You can also change d.z from the direction vector d. But
if you change d.x or d.y, then the fill area goes out of the target plane.
I only miss one rotation angel (rx), I tried several combinations of
trigonometrics, but none of them were correct.
Any help would be thankfully appreciaded. If I have solved this problem, I'm
ready to share some - I believe - very helpful modules for OpenSCAD.
Regards
--
Sent from: http://forum.openscad.org/
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
function unit(v) = let(n = norm(v)) n ? v / n : v; // Convert v to a unit
vector
function orientate(p, r) = // Matrix to translate to p and rotate to r
let(x = r[0], y = r[1], z = r[2])
[[x.x, x.y, x.z, p.x],
[y.x, y.y, y.z, p.y],
[z.x, z.y, z.z, p.z],
[ 0, 0, 0, 1 ]];
//----------------------------------
// WorkInProgress
// fill area spanned by p1-p2 and d
//----------------------------------
module fill(p1,p2,d)
{
// this is the vector
v=p2-p1;
// length of vector
l=norm(v);
// length of d
h=norm(d);
// angel between v and d is amout to shear
sxy=angel(v,d);
tangent = v;
normal = d;
binormal = cross(tangent, normal);
x = unit(tangent);
z = unit(binormal);
y = -unit(cross(tangent, binormal));
rot = [[x.x, y.x, z.x],
[x.y, y.y, z.y],
[x.z, y.z, z.z]];
multmatrix(orientate(p1, rot) * sxy(sxy))
area(l,h,"p1","p2","p1+d","p2+d");
// DEBUG: show sheared area before translate/rotate
#multmatrix(sxy(sxy)) area(l,h,"p1","p2","p1+d","p2+d");
}
On Sat, 31 Oct 2020 at 08:38, jjvbhh jjvb-openscad@bassklampfe.de wrote:
I have reduced my problem (see
Trouble-with-rotating-Text-to-correct-orientation
<
http://forum.openscad.org/Trouble-with-rotating-Text-to-correct-orientation-td30280.html>
) to one rotating angel, I cannot find the correct calculation.
The task is to span an area between two points P1 and P2 in a direction
given by a direction vector D (which is identical to the problem in the
subject).
The image illustrates it:
http://forum.openscad.org/file/t2988/span-area.jpg
If you load the attached script ( span-area.scad
http://forum.openscad.org/file/t2988/span-area.scad ) into OpenSCAD and
open the Customizer, you can move P1 and P2 anywhere and the grey fill area
is placed perfect. You can also change d.z from the direction vector d. But
if you change d.x or d.y, then the fill area goes out of the target plane.
I only miss one rotation angel (rx), I tried several combinations of
trigonometrics, but none of them were correct.
Any help would be thankfully appreciaded. If I have solved this problem,
I'm
ready to share some - I believe - very helpful modules for OpenSCAD.
Regards
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Bit more concise version:
binormal = cross(v, d);
x = unit(v);
z = unit(binormal);
y = unit(cross(binormal, v));
On Sat, 31 Oct 2020 at 11:47, nop head nop.head@gmail.com wrote:
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
function unit(v) = let(n = norm(v)) n ? v / n : v; // Convert v to a unit
vector
function orientate(p, r) = // Matrix to translate to p and rotate to r
let(x = r[0], y = r[1], z = r[2])
[[x.x, x.y, x.z, p.x],
[y.x, y.y, y.z, p.y],
[z.x, z.y, z.z, p.z],
[ 0, 0, 0, 1 ]];
//----------------------------------
// WorkInProgress
// fill area spanned by p1-p2 and d
//----------------------------------
module fill(p1,p2,d)
{
// this is the vector
v=p2-p1;
// length of vector
l=norm(v);
// length of d
h=norm(d);
// angel between v and d is amout to shear
sxy=angel(v,d);
tangent = v;
normal = d;
binormal = cross(tangent, normal);
x = unit(tangent);
z = unit(binormal);
y = -unit(cross(tangent, binormal));
rot = [[x.x, y.x, z.x],
[x.y, y.y, z.y],
[x.z, y.z, z.z]];
multmatrix(orientate(p1, rot) * sxy(sxy))
area(l,h,"p1","p2","p1+d","p2+d");
// DEBUG: show sheared area before translate/rotate
#multmatrix(sxy(sxy)) area(l,h,"p1","p2","p1+d","p2+d");
}
On Sat, 31 Oct 2020 at 08:38, jjvbhh jjvb-openscad@bassklampfe.de wrote:
I have reduced my problem (see
Trouble-with-rotating-Text-to-correct-orientation
<
http://forum.openscad.org/Trouble-with-rotating-Text-to-correct-orientation-td30280.html>
) to one rotating angel, I cannot find the correct calculation.
The task is to span an area between two points P1 and P2 in a direction
given by a direction vector D (which is identical to the problem in the
subject).
The image illustrates it:
http://forum.openscad.org/file/t2988/span-area.jpg
If you load the attached script ( span-area.scad
http://forum.openscad.org/file/t2988/span-area.scad ) into OpenSCAD
and
open the Customizer, you can move P1 and P2 anywhere and the grey fill
area
is placed perfect. You can also change d.z from the direction vector d.
But
if you change d.x or d.y, then the fill area goes out of the target
plane.
I only miss one rotation angel (rx), I tried several combinations of
trigonometrics, but none of them were correct.
Any help would be thankfully appreciaded. If I have solved this problem,
I'm
ready to share some - I believe - very helpful modules for OpenSCAD.
Regards
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
nophead wrote
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
Yes, works fine! Your great, many thanks for your quick response. This
really brings me a giant step forward my targets. Now I only have to
understand your magic code.
I will come back soon with some fine measure modules
Regards
--
Sent from: http://forum.openscad.org/
My code basically sets up a new coordinate system aligned to the vectors
and then maps the original plane x, y, z to that new set of axes.
On Sat, 31 Oct 2020 at 12:36, jjvbhh jjvb-openscad@bassklampfe.de wrote:
nophead wrote
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
Yes, works fine! Your great, many thanks for your quick response. This
really brings me a giant step forward my targets. Now I only have to
understand your magic code.
I will come back soon with some fine measure modules
Regards
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The new x axis is along v. The new z axis is at right angles to both v and
d by taking the cross product. The new y axis is then at right angles to
both z and x using another cross product.
On Sat, 31 Oct 2020 at 12:38, nop head nop.head@gmail.com wrote:
My code basically sets up a new coordinate system aligned to the vectors
and then maps the original plane x, y, z to that new set of axes.
On Sat, 31 Oct 2020 at 12:36, jjvbhh jjvb-openscad@bassklampfe.de wrote:
nophead wrote
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
Yes, works fine! Your great, many thanks for your quick response. This
really brings me a giant step forward my targets. Now I only have to
understand your magic code.
I will come back soon with some fine measure modules
Regards
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 2020-10-31 12:47, nop head wrote:
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
Why such complicated approach? What is wrong with simply adding the
vector to the two points to obtain the rectangle area?
Carsten Arnholm
It isn't a rectangle, it is a parallelogram with sheared text on it.
On Sat, 31 Oct 2020 at 12:49, arnholm@arnholm.org wrote:
On 2020-10-31 12:47, nop head wrote:
Euler rotations always confuse me so I did it with Frenet-Seret style
vector maths. Seems to work.
Why such complicated approach? What is wrong with simply adding the
vector to the two points to obtain the rectangle area?
Carsten Arnholm
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 2020-10-31 13:51, nop head wrote:
It isn't a rectangle, it is a parallelogram with sheared text on it.
My question still stands if it is a parallelogram
Carsten Arnholm
So what is your solution to construct a transform to rotate and shear a
plane to align with an arbitrary parallelogram?
On Sat, 31 Oct 2020 at 12:56, arnholm@arnholm.org wrote:
On 2020-10-31 13:51, nop head wrote:
It isn't a rectangle, it is a parallelogram with sheared text on it.
My question still stands if it is a parallelogram
Carsten Arnholm
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org