discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Problems with difference

RP
Ronaldo Persiano
Sat, Jan 2, 2021 7:23 AM

The stack and pips are nice solutions.

The rotation rotFromTo(a,b) is the rotation with minimum angle that maps
the direction of vector a to the direction of vector b. It can be coded
in many ways. As a function returning a 4x4 matrix, it can be found in the
Tips&Tricks
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Minimum_rotation_problem
page
of the OpenSCAD Manual. As a module, I like the following:

module rotFromTo(di,do) {
if( norm(di) < 1e-16 || norm(do) < 1e-16 ||
norm(do/norm(do)+di/norm(di))<1e-16 )
children();
else
mirror(do/norm(do)+di/norm(di)) mirror(di) children();
}

The stack and pips are nice solutions. The rotation rotFromTo(a,b) is the rotation with minimum angle that maps the direction of vector `a` to the direction of vector `b`. It can be coded in many ways. As a function returning a 4x4 matrix, it can be found in the Tips&Tricks <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Minimum_rotation_problem> page of the OpenSCAD Manual. As a module, I like the following: module rotFromTo(di,do) { if( norm(di) < 1e-16 || norm(do) < 1e-16 || norm(do/norm(do)+di/norm(di))<1e-16 ) children(); else mirror(do/norm(do)+di/norm(di)) mirror(di) children(); }
P
Parkinbot
Sat, Jan 2, 2021 2:58 PM

Found a nice way to calculate your flattened diamond, which I understand is
the primitive you are going to print:

module flattened_diamond(){

p = [v[0], v[6], v[18], v[8], v[20], [0,0,0]];  // add origin
intersection()
{
scale(1.5) hull() polyhedron(p, [[0,1,2,3,4, 5]]);
diamond();
}
}

--
Sent from: http://forum.openscad.org/

Found a nice way to calculate your flattened diamond, which I understand is the primitive you are going to print: module flattened_diamond(){ p = [v[0], v[6], v[18], v[8], v[20], [0,0,0]]; // add origin intersection() { scale(1.5) hull() polyhedron(p, [[0,1,2,3,4, 5]]); diamond(); } } -- Sent from: http://forum.openscad.org/
P
Parkinbot
Sat, Jan 2, 2021 4:16 PM

Ups, sorry, I just read that Ronaldo came up with the same approach ...

--
Sent from: http://forum.openscad.org/

Ups, sorry, I just read that Ronaldo came up with the same approach ... -- Sent from: http://forum.openscad.org/