Giter Club home page Giter Club logo

obiscad's Introduction

obiscad

Obijuan openscad tools

Enhance your openscad designs!

obiscad's People

Contributors

carlosgs avatar jakobwenzel avatar justbuchanan avatar maaajaaa avatar obijuan avatar valerioa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obiscad's Issues

Trouble in beveling the top edge of a cylinder

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.

image

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:

image

image

I will provide updates, as I discover more.

Attach does not apply rotation with connectors pointing in opposite directions

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];

connector(c1);

connector(c2);

connector(c3);

//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]);
}

Angle between faces affectson beveling

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.

image

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.

image

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)

image

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:

image

with the original bconcave_corner_aux() it would look like:

image

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.

Roll of attached part is ignored

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?

Libraries contain top level objects

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.