3 ms·
Haven't tried OpenJSCAD - thanks for the reference. > Referring to vertices of a solid in general seems to be incompatible with OpenSCAD's paradigm of modelin
by ajb 6y ago
Haven't tried OpenJSCAD - thanks for the reference.
> Referring to vertices of a solid in general seems to be incompatible with OpenSCAD's paradigm of modeling with boolean operations. You don't know where the vertices are until you render.
Is it? Well I suppose it is in the general case. It would be hard to refer to an edge that has been created as a result of some difference operation. But the corners of a cube are still valid reference points even if they've been chopped off, and aren't part of the final solid.
- romwell 6y agoI guess so, but I find it a mild inconvenience personally. I'd struggle to come up with an example where it would be a deal-breaker. Could you write about how you'd use it? Incidentally, I ended up needing a function that places a cylinder between two points in OpenSCAD yesterday. Here is my implementation - might come in handy! // Transpose of matrix A (swap rows and columns) function transpose(A) = [for (j = [0:len(A[0])-1]) [for(i = [0:len(A)-1]) A[i][j]]]; // Cylinder of radius r from P to Q module cyl_between(P, Q, r){ v = Q - P; // vector from P to Q L = norm(v); // height of the cylnder = dist(P, Q) c = v / L; // unit vector: direction from P to Q is_c_vertical = ( 1 - abs(c * [0, 0, 1]) < 1e-6); //is c parallel to z axis? u = is_c_vertical ? [1, 0, 0] : cross([0, 0, 1], c); // normal to c and Z axis a = u / norm(u); // unit vector normal to c and the Z axis b = cross(c, a); // unit vector normal to a and b // [a, b, c] is an orthonormal basis, i.e. the rotation matrix; P is the translation MT = [a, b, c, P]; // the transformation matrix M = transpose(MT); // OpenSCAD wants vectors in columns, so we need to transpose multmatrix(M) cylinder(h=L, r=r, $fn=24); }