Obijuan openscad tools
Enhance your openscad designs!
Obijuan openscad tools
The short summary of my problem is that, in trying to bevel the top of a cylinder, I noticed some bevel segments are not oriented correctly.
The image is generated with:
use <obiscad/bevel.scad> use <obiscad/attach.scad> epsilon=1e-3; function getBevelConnectors(p1, p2, ft1, ft2) = [ [((p1+p2)/2), (p2-p1)/norm(p2-p1), 0], [((p1+p2)/2), (cross( ft1[2] - ft1[1], ft1[0] - ft1[1]) / norm(cross( ft1[2] - ft1[1], ft1[0] - ft1[1])) + cross( ft2[2] - ft2[1], ft2[0] - ft2[1]) / norm(cross( ft2[2] - ft2[1], ft2[0] - ft2[1])) ) / norm((cross( ft1[2] - ft1[1], ft1[0] - ft1[1]) / norm(cross( ft1[2] - ft1[1], ft1[0] - ft1[1])) + cross( ft2[2] - ft2[1], ft2[0] - ft2[1]) / norm(cross( ft2[2] - ft2[1], ft2[0] - ft2[1])) )), 0 ] ]; translate([0,0,-10]) cylinder(r=20,h=10); p = [ for(a=[0:10:360]) [cos(a)*20, sin(a)*20, 0] ]; union(){ for(i=[0:1:len(p)-2]) { bc1 = getBevelConnectors(p[i], p[i+1], [p[i], p[i+1]-[0,0,10], p[i+1]], [p[i], p[i+1], [0,0,0]]) ; color([1,0,0]) bevel(bc1[0], bc1[1],cr = 2, cres=50, l=norm(p[i+1]-p[i])+epsilon); } };
I wrote the following function to compute bevel connectors for any arbitrary edge:
p1 & p2 are the endpoints of the edge, ft1 & ft2 are two triangles lying on the faces separated by the edge. Triangle are needed to calculate connectors. Points of the triangles have to be ordered according to the right hand rule for proper vector calculations.
function getBevelConnectors(p1, p2, ft1, ft2) = [ [((p1+p2)/2), (p2-p1)/norm(p2-p1), 0], [((p1+p2)/2), (cross( ft1[2] - ft1[1], ft1[0] - ft1[1]) / norm(cross( ft1[2] - ft1[1], ft1[0] - ft1[1])) + cross( ft2[2] - ft2[1], ft2[0] - ft2[1]) / norm(cross( ft2[2] - ft2[1], ft2[0] - ft2[1])) ) / norm((cross( ft1[2] - ft1[1], ft1[0] - ft1[1]) / norm(cross( ft1[2] - ft1[1], ft1[0] - ft1[1])) + cross( ft2[2] - ft2[1], ft2[0] - ft2[1]) / norm(cross( ft2[2] - ft2[1], ft2[0] - ft2[1])) )), 0 ] ];
It seems to me that, for a circle lying on the [x,y] plane at z=0, bevels are not oriented correctly for edges that are formed at angle >= 90 & angle <=135. And, symmetrically, at angle >=180 & angle <=225.
Images below show that connectors to generate all bevels are oriented correctly:
I will provide updates, as I discover more.
If you have 2 connector pointing in exactly opposite direction, then attaching 2 parts with these connector will not apply the 180 degree rotation. Supposedly the cross product of the vectors is 0, and therefor the OpenScad rotate() function does nothing, because it is given a zero vector to rotate around.
Example:
c1 = [[0,0,0] , [-1,0,0], 0];
c2 = [[0,0,0] , [1,0,0], 0];
c3 = [[0,0,0] , [1,0.0001,0], 0];
//not working correctly
attach(c1,c2) {
color("blue") cube([30,10,5]);
}
//workaround by moving the connector vector a tiny bit
attach(c1,c3) {
color("red") cube([30,10,5]);
}
Hi Juan,
I observed the following problem: beveling is correct only when the angle between the faces is 90 deg. If the angle is < 90 the bevel is acceptable, but it is geometrically incorrect, as it flattens more, the more acute the angle is. If the angle is > than 90 deg, the bevel is carved out.
This is due, as you know, to the bevel being constructed out of a cube.
I have a pull request that makes a geometrically correct bevel, irrespective of the angle between the faces, by building the beveling surface out of a triangular prism.
The base of the triangular prism is built as (the base of the prism is green; the section of the cylinder that is subtracted from the prism is red)
With that, bconcave_corner_aux() becomes:
module bconcave_corner_aux(cr,cres,l,th,alpha=90) { a = cr * cos(90-(alpha/2)); b = cr * sin(90-(alpha/2)); d = b / sin(alpha/2); c = d * cos(alpha/2); e = d * cos(45+(alpha/2)); f = d * sin(45+(alpha/2)); difference() { translate([0,0,-l/2]) linear_extrude( height = l, center = false, convexity = 20, twist = 0) polygon(points=[ [0-th,0-th], [e-th,f], [e,f], [f,e], [f,e-th] ], convexity=20); translate([(a+c)*cos(45),(a+c)*sin(45),0]) color([1,0,0]) cylinder(r=cr, h=l+1, center=true, $fn=4*(cres+1)); } }
In order for it to work correctly, the translations have to be removed from bconcave_corner()
module bconcave_corner(cr=1,cres=4,th=1,l=10,ext_corner=false,alpha=90) { //-- Locate the origin in the exterior edge if (ext_corner==true) //translate([0,0,0]) bconcave_corner_aux(cr,cres,l,th,alpha=alpha); else //-- Locate the origin in the interior edge //translate([0.0, 0.0,0]) bconcave_corner_aux(cr,cres,l,th,alpha=alpha); }
I came to this while trying to design a NEMA 17 body to be subtracted out of a motor mount:
with the original bconcave_corner_aux() it would look like:
I have added an "alpha" argument to all modules. The argument defaults to 90 deg., thus this pull is fully backward compatible.
I will follow up with a pull request.
When attaching a part, the roll parameter of the second connector is ignored. This is an intentional design choice, as the code is commented with "The rolling angle of the attachable part is not used".
While it doesn't provide any additional capability to use this angle, it's confusing that it's ignored. Is there some reason to ignore it?
The licence of this library seems to be Creative Commons โ. Attribution โ Share Alike 3.0, as can be seen from its entry on Thingiverse.
Would be great to make that explicit in this Github repository by including a LICENCE file.
The libraries contain top level objects. You have to clean the libraries before using them, making syncing them with Git a pain.
Libraries should not contain top level objects. There is an examples folder for examples.
Followed the tutorial here:
http://www.iearobotics.com/blog/2012/09/13/enhancing-openscad-ii-bevel-library/
Noticed a bit of visual tearing along the edge of the bevel. Changed to front view, orthogonal and zoomed in, saw this:
http://i.imgur.com/AEYRS1x.png
The offset looks minor, but of course with designing parts you don't want to have issues like this, you want your models to be clean.
OpenSCAD 2014.03.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.