discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Points for tangents to two circles

IO
Ian Oliver
Thu, Jul 6, 2017 3:36 PM

In case anyone finds it useful ...

https://www.thingiverse.com/thing:2421943

"Some simple OpenSCAD to get the points for lines that are tangential to
two arbitrary circles.

I found myself bodging this a lot so used Prof. Google to get some
equations to do it properly.

Enjoy!"

In case anyone finds it useful ... https://www.thingiverse.com/thing:2421943 "Some simple OpenSCAD to get the points for lines that are tangential to two arbitrary circles. I found myself bodging this a lot so used Prof. Google to get some equations to do it properly. Enjoy!"
MC
Mr C Camacho
Thu, Jul 6, 2017 5:33 PM

what is the prof google ?

On 06/07/17 16:36, Ian Oliver wrote:

In case anyone finds it useful ...

https://www.thingiverse.com/thing:2421943

"Some simple OpenSCAD to get the points for lines that are tangential
to two arbitrary circles.

I found myself bodging this a lot so used Prof. Google to get some
equations to do it properly.

Enjoy!"


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

what is the prof google ? On 06/07/17 16:36, Ian Oliver wrote: > In case anyone finds it useful ... > > https://www.thingiverse.com/thing:2421943 > > "Some simple OpenSCAD to get the points for lines that are tangential > to two arbitrary circles. > > I found myself bodging this a lot so used Prof. Google to get some > equations to do it properly. > > Enjoy!" > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
IO
Ian Oliver
Thu, Jul 6, 2017 6:31 PM

On 2017-07-06 18:33, Mr C Camacho wrote:

what is the prof google ?

Just googling for likely pages and my scad files link to the ones I
used. I was really just flagging that the maths are stolen and I just
did the monkey see, monkey do.

On 2017-07-06 18:33, Mr C Camacho wrote: > what is the prof google ? Just googling for likely pages and my scad files link to the ones I used. I was really just flagging that the maths are stolen and I just did the monkey see, monkey do.
MC
Mr C Camacho
Thu, Jul 6, 2017 6:56 PM

oh right! doh!

I was thinking there was some soon to be shuttered google service that
would take sets of data and produce a formula!

On 06/07/17 19:31, Ian Oliver wrote:

On 2017-07-06 18:33, Mr C Camacho wrote:

what is the prof google ?

Just googling for likely pages and my scad files link to the ones I
used. I was really just flagging that the maths are stolen and I just
did the monkey see, monkey do.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

oh right! doh! I was thinking there was some soon to be shuttered google service that would take sets of data and produce a formula! On 06/07/17 19:31, Ian Oliver wrote: > On 2017-07-06 18:33, Mr C Camacho wrote: >> what is the prof google ? > > Just googling for likely pages and my scad files link to the ones I > used. I was really just flagging that the maths are stolen and I just > did the monkey see, monkey do. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
D
droftarts
Thu, Jul 6, 2017 9:52 PM

I was trying to write a script to draw tangents of circles a while ago:
http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-td16537.html

I can't remember where I got the maths from.

Nophead supplied this very neat answer, that allows for different radii of
the circles, and negative radii for concave shapes - hull and minkowski
can't do that!:
http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16556.html

Ian

--
View this message in context: http://forum.openscad.org/Points-for-tangents-to-two-circles-tp21782p21786.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I was trying to write a script to draw tangents of circles a while ago: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-td16537.html I can't remember where I got the maths from. Nophead supplied this very neat answer, that allows for different radii of the circles, and negative radii for concave shapes - hull and minkowski can't do that!: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16556.html Ian -- View this message in context: http://forum.openscad.org/Points-for-tangents-to-two-circles-tp21782p21786.html Sent from the OpenSCAD mailing list archive at Nabble.com.
IO
Ian Oliver
Fri, Jul 7, 2017 10:22 AM

On 2017-07-06 22:52, droftarts wrote:

Nophead supplied this very neat answer, that allows for different radii of
the circles, and negative radii for concave shapes

Wow, and very nice it is too. A neater way of creating the very shape I
wanted from my tangent code, as it happens, and easier to use!

On 2017-07-06 22:52, droftarts wrote: > Nophead supplied this very neat answer, that allows for different radii of > the circles, and negative radii for concave shapes Wow, and very nice it is too. A neater way of creating the very shape I wanted from my tangent code, as it happens, and easier to use!
NH
nop head
Fri, Jul 7, 2017 1:58 PM

I use it for complex belt paths around different sized pulleys, for example
an H-bot I a working on.

On 7 July 2017 at 11:22, Ian Oliver lists@foxhill.co.uk wrote:

On 2017-07-06 22:52, droftarts wrote:

Nophead supplied this very neat answer, that allows for different radii of
the circles, and negative radii for concave shapes

Wow, and very nice it is too. A neater way of creating the very shape I
wanted from my tangent code, as it happens, and easier to use!


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I use it for complex belt paths around different sized pulleys, for example an H-bot I a working on. On 7 July 2017 at 11:22, Ian Oliver <lists@foxhill.co.uk> wrote: > On 2017-07-06 22:52, droftarts wrote: > >> Nophead supplied this very neat answer, that allows for different radii of >> the circles, and negative radii for concave shapes >> > > Wow, and very nice it is too. A neater way of creating the very shape I > wanted from my tangent code, as it happens, and easier to use! > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
D
droftarts
Sat, Jul 8, 2017 7:49 AM

Hi nophead

Presumably you've added a bit to the script that adds up the length of the
tangents, and the arcs of where the belt is on the pulley, to come up with
the belt length?

Ian

--
View this message in context: http://forum.openscad.org/Points-for-tangents-to-two-circles-tp21782p21791.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi nophead Presumably you've added a bit to the script that adds up the length of the tangents, and the arcs of where the belt is on the pulley, to come up with the belt length? Ian -- View this message in context: http://forum.openscad.org/Points-for-tangents-to-two-circles-tp21782p21791.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Sat, Jul 8, 2017 9:43 AM

Yes indeed although I haven't actually cut a belt to test it yet.

//
//        p  w  t    t    p
//        i  i  h    o    i
//        t  d  i    o    t
//        c  t  c    t    c
//        h  h  k    h    h line from tooth base
//
T5x6 =  [  5,  6, 2.2,  1.2,  0.5];
T5x10 = [  5, 10, 2.2,  1.2,  0.5];
T2p5x6 =[2.5,  6, 1.7,  0.7,  0.3];
GT2x6 = [2.0,  6, 1.38, 0.75, 0.254];

function belt_pitch(type)        = type[0];
function belt_width(type)        = type[1];
function belt_thickness(type)    = type[2];
function belt_tooth_height(type) = type[3];
function belt_pitch_height(type) = belt_tooth_height(type) + type[4];

belt_colour = grey20;
tooth_colour = grey50;
//
// We model the belt path at the pitch radius of the pulleys and the pitch
line of the belt to get an accurate length.
// The belt is then drawn by offseting each side from the pitch line.
//
module belt(type, points, gap = 0, gap_pt = undef) {
width = belt_width(type);
pitch = belt_pitch(type);
thickness = belt_thickness(type);

vitamin(str("BT", belt_pitch(type) * 10,width, round(length), ": Belt

T", belt_pitch(type)," x ", width, "mm x ", length, "mm"));

function tangent(p1, p2) =
    let(
        r1 = p1[2],
        r2 = p2[2],
        dx = p2.x - p1.x,
        dy = p2.y - p1.y,
        d = sqrt(dx * dx + dy * dy),
        theta = atan2(dy, dx) + acos((r1 - r2) / d),
        xa = p1.x +(cos(theta) * r1),
        ya = p1.y +(sin(theta) * r1),
        xb = p2.x +(cos(theta) * r2),
        yb = p2.y +(sin(theta) * r2)
    )[ [xa, ya], [xb, yb] ];

len = len(points);
indices = [0 : len - 1];

tangents = [for(i = indices)
                let(ends = tangent(points[i], points[(i + 1) % len]))
                    for(end = [0, 1])
                        ends[end]];

straights = [for(i = indices) norm(tangents[2 * i] - tangents[2 * i +

1])];
arcs = [for(i = indices) let(p1 = tangents[2 * i + 1],
p2 = tangents[(2 * i + 2) % (2 * len)],
corner = points[(i + 1) % len],
c = [corner.x, corner.y],
v1 = p1 - c,
v2 = p2 - c,
r = abs(corner.z)) PI * acos((v1 * v2) /
sqr(r)) * r / 180];

function sumv(v, i = 0, sum = 0) = i == len(v) ? sum : sumv(v, i + 1,

sum + v[i]);

length = ceil((sumv(concat(straights, arcs)) - gap) / pitch) * pitch;

//echo(straights, arcs, length);

module shape() {
    difference() {
        union() {
            for(i = indices)
                if(points[i][2] > 0)
                    translate([points[i].x, points[i].y])
                        circle(points[i][2]);

            polygon(tangents);
        }
        for(i = indices)
            if(points[i][2] < 0)
                translate([points[i].x, points[i].y])
                    circle(-points[i][2]);
     }
}

module gap()
    if(gap)
        translate(gap_pt)
            square([gap, thickness + eps], center = true);

color(belt_colour) render(convexity = len)
    linear_extrude(height = width, center = true)
        difference() {
            offset(thickness - belt_pitch_height(type)) shape();
            offset(-belt_pitch_height(type) + belt_tooth_height(type))

shape();
gap();

        }
color(tooth_colour) render(convexity = len)
    linear_extrude(height = width, center = true)
        difference() {
            offset(-belt_pitch_height(type) + belt_tooth_height(type))

shape();
offset(-belt_pitch_height(type)) shape();
gap();
}
}

On 8 July 2017 at 08:49, droftarts ginjaian@hotmail.com wrote:

Hi nophead

Presumably you've added a bit to the script that adds up the length of the
tangents, and the arcs of where the belt is on the pulley, to come up with
the belt length?

Ian

--
View this message in context: http://forum.openscad.org/
Points-for-tangents-to-two-circles-tp21782p21791.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes indeed although I haven't actually cut a belt to test it yet. // // p w t t p // i i h o i // t d i o t // c t c t c // h h k h h line from tooth base // T5x6 = [ 5, 6, 2.2, 1.2, 0.5]; T5x10 = [ 5, 10, 2.2, 1.2, 0.5]; T2p5x6 =[2.5, 6, 1.7, 0.7, 0.3]; GT2x6 = [2.0, 6, 1.38, 0.75, 0.254]; function belt_pitch(type) = type[0]; function belt_width(type) = type[1]; function belt_thickness(type) = type[2]; function belt_tooth_height(type) = type[3]; function belt_pitch_height(type) = belt_tooth_height(type) + type[4]; belt_colour = grey20; tooth_colour = grey50; // // We model the belt path at the pitch radius of the pulleys and the pitch line of the belt to get an accurate length. // The belt is then drawn by offseting each side from the pitch line. // module belt(type, points, gap = 0, gap_pt = undef) { width = belt_width(type); pitch = belt_pitch(type); thickness = belt_thickness(type); vitamin(str("BT", belt_pitch(type) * 10,width, round(length), ": Belt T", belt_pitch(type)," x ", width, "mm x ", length, "mm")); function tangent(p1, p2) = let( r1 = p1[2], r2 = p2[2], dx = p2.x - p1.x, dy = p2.y - p1.y, d = sqrt(dx * dx + dy * dy), theta = atan2(dy, dx) + acos((r1 - r2) / d), xa = p1.x +(cos(theta) * r1), ya = p1.y +(sin(theta) * r1), xb = p2.x +(cos(theta) * r2), yb = p2.y +(sin(theta) * r2) )[ [xa, ya], [xb, yb] ]; len = len(points); indices = [0 : len - 1]; tangents = [for(i = indices) let(ends = tangent(points[i], points[(i + 1) % len])) for(end = [0, 1]) ends[end]]; straights = [for(i = indices) norm(tangents[2 * i] - tangents[2 * i + 1])]; arcs = [for(i = indices) let(p1 = tangents[2 * i + 1], p2 = tangents[(2 * i + 2) % (2 * len)], corner = points[(i + 1) % len], c = [corner.x, corner.y], v1 = p1 - c, v2 = p2 - c, r = abs(corner.z)) PI * acos((v1 * v2) / sqr(r)) * r / 180]; function sumv(v, i = 0, sum = 0) = i == len(v) ? sum : sumv(v, i + 1, sum + v[i]); length = ceil((sumv(concat(straights, arcs)) - gap) / pitch) * pitch; //echo(straights, arcs, length); module shape() { difference() { union() { for(i = indices) if(points[i][2] > 0) translate([points[i].x, points[i].y]) circle(points[i][2]); polygon(tangents); } for(i = indices) if(points[i][2] < 0) translate([points[i].x, points[i].y]) circle(-points[i][2]); } } module gap() if(gap) translate(gap_pt) square([gap, thickness + eps], center = true); color(belt_colour) render(convexity = len) linear_extrude(height = width, center = true) difference() { offset(thickness - belt_pitch_height(type)) shape(); offset(-belt_pitch_height(type) + belt_tooth_height(type)) shape(); gap(); } color(tooth_colour) render(convexity = len) linear_extrude(height = width, center = true) difference() { offset(-belt_pitch_height(type) + belt_tooth_height(type)) shape(); offset(-belt_pitch_height(type)) shape(); gap(); } } On 8 July 2017 at 08:49, droftarts <ginjaian@hotmail.com> wrote: > Hi nophead > > Presumably you've added a bit to the script that adds up the length of the > tangents, and the arcs of where the belt is on the pulley, to come up with > the belt length? > > Ian > > > > -- > View this message in context: http://forum.openscad.org/ > Points-for-tangents-to-two-circles-tp21782p21791.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
I
irevdev
Sat, Jul 22, 2017 12:41 PM

I may be doing something similar  here
https://github.cohttps://github.com/Irev-Dev/Round-Anything/blob/master/polyround.scadm/Irev-Dev/Round-Anything/blob/master/polyround.scad
but in reverse? Finding the tangent points for two lines and a circle.

http://forum.openscad.org/file/n21898/PolyRoundexample1.png

--
View this message in context: http://forum.openscad.org/Points-for-tangents-to-two-circles-tp21782p21898.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I may be doing something similar here <https://github.cohttps://github.com/Irev-Dev/Round-Anything/blob/master/polyround.scadm/Irev-Dev/Round-Anything/blob/master/polyround.scad> but in reverse? Finding the tangent points for two lines and a circle. <http://forum.openscad.org/file/n21898/PolyRoundexample1.png> -- View this message in context: http://forum.openscad.org/Points-for-tangents-to-two-circles-tp21782p21898.html Sent from the OpenSCAD mailing list archive at Nabble.com.