# Simple trigonometry problem (I think I should go back to school)

6 messages
Open this post in threaded view
|

## Simple trigonometry problem (I think I should go back to school)

Open this post in threaded view
|

## Re: Simple trigonometry problem (I think I should go back to school)

Open this post in threaded view
|

## Re: Simple trigonometry problem (I think I should go back to school)

Open this post in threaded view
|

## Re: Simple trigonometry problem (I think I should go back to school)

 In reply to this post by gounthar On 2020-11-26 16:17, Verachten Bruno wrote: > I have four holes, forming a rectangle. I have then four feets. I'm > trying to join 2 feet by a diagonal cylinder. So I'm dividing the > opposite side by the adjacent side, and applying atan() on the result, > to hopefully find the angle I'm supposed to use in rotate(). > Unfortunately, that does not fit correctly, I'm a few degrees wrong. There is no need to use trigonometric functions for something like this. Try this to replace your link module link(points, thickness, height) {      pdx = points[3][0] - points[0][0];      pdy = points[3][1] - points[0][1];      length = sqrt(pow(pdx,2) + pow(pdy,2));      dx = pdx/length;      dy = pdy/length;      color("blue")      translate([0,0,height*2])      multmatrix([[dx,-dy,0,0],[dy,dx,0,0],[0,0,1,0],[0,0,0,1]])      rotate([0,90,0])      cylinder(h=length, r=thickness/2, center=false, \$fn=100); } You already have the direction cosines, so you just need to apply them. Carsten Arnholm _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org