Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #59

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Dev #59

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions constants.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include <MCAD/general/constants.scad>;

echo("This file (MCAD/constants.scad) is depreciated and exists only to ensure compatibility with older scripts. Could you please update your script to include MCAD/general/constants.scad? At some point of time, the file MCAD/constants.scad will be deleted. Further more, we have a new naming scheme for MCAD constants. They begin with \"mcad_const_xyzName\".\n Thank you!");

// MIT license
// Author: Elmo Mäntynen

TAU = 6.2831853071; //2*PI, see http://tauday.com/
PI = TAU/2;

// translates a imperial measurement in inches to meters
mm_per_inch = 25.4;

2 changes: 1 addition & 1 deletion curves.scad
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ z(t) = b*t
*/


function b(pitch) = pitch/(const_tau);
function b(pitch) = pitch/(mcad_const_tau);
function t(pitch, z) = z/b(pitch);

function helix_curve(pitch, radius, z) =
Expand Down
20 changes: 10 additions & 10 deletions demos/constants_demo.scad
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include <MCAD/general/constants.scad>;

echo(const_e = const_e);
echo(const_pi = const_pi);
echo(const_tau = const_tau);
echo(const_phi = const_phi);
echo(const_sqrt2 = const_sqrt2);
echo(const_sqrt2 * const_sqrt2);
echo(const_sqrt3 = const_sqrt3);
echo(const_sqrt3 * const_sqrt3);
echo(const_sqrt5 = const_sqrt5);
echo(const_sqrt5 * const_sqrt5);
echo(mcad_const_e = mcad_const_e);
echo(mcad_const_pi = mcad_const_pi);
echo(mcad_const_tau = mcad_const_tau);
echo(mcad_const_phi = mcad_const_phi);
echo(mcad_const_sqrt2 = mcad_const_sqrt2);
echo(mcad_const_sqrt2 * mcad_const_sqrt2);
echo(mcad_const_sqrt3 = mcad_const_sqrt3);
echo(mcad_const_sqrt3 * mcad_const_sqrt3);
echo(mcad_const_sqrt5 = mcad_const_sqrt5);
echo(mcad_const_sqrt5 * mcad_const_sqrt5);
6 changes: 3 additions & 3 deletions fasteners/iso4017.scad
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ $fn = 36;
module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false)
{
dimensions = iso_hexagon_head_screw_dimensions(diameter);
hex_side_nom = dimensions[18] / const_sqrt3;
hex_side_grade_a = dimensions[19] / const_sqrt3;
hex_side_grade_b = dimensions[20] / const_sqrt3;
hex_side_nom = dimensions[18] / mcad_const_sqrt3;
hex_side_grade_a = dimensions[19] / mcad_const_sqrt3;
hex_side_grade_b = dimensions[20] / mcad_const_sqrt3;

echo(dimensions);
echo(dimensions[8] / 2, hex_side_nom);
Expand Down
8 changes: 5 additions & 3 deletions fasteners/threads.scad
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* Version 1.1. 2012-09-07 Corrected to right-hand threads!
*/

include <MCAD/general/constants.scad>

// Examples:

test_threads ();
Expand Down Expand Up @@ -234,9 +236,9 @@ module english_thread(diameter=0.25, threads_per_inch=20, length=1,
internal=false, n_starts=1)
{
// Convert to mm.
mm_diameter = diameter*25.4;
mm_pitch = (1.0/threads_per_inch)*25.4;
mm_length = length*25.4;
mm_diameter = diameter*mcad_const_mm_per_inch; // diameter*25.4
mm_pitch = (1.0/threads_per_inch)*mcad_const_mm_per_inch;
mm_length = length*mcad_const_mm_per_inch;

echo(str("mm_diameter: ", mm_diameter));
echo(str("mm_pitch: ", mm_pitch));
Expand Down
14 changes: 7 additions & 7 deletions gears/rack_and_pinion.scad
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ module rack(cp, N, width, thickness){
// width = width of rack
// thickness = thickness of support under teeth (0 for no support)

a = 1.0*cp/const_pi; // addendum (also known as "module")
d = 1.1*cp/const_pi; // dedendum (this is set by a standard)
a = 1.0*cp/mcad_const_pi; // addendum (also known as "module")
d = 1.1*cp/mcad_const_pi; // dedendum (this is set by a standard)
height=(d+a);

// find the tangent of pressure angle once
Expand Down Expand Up @@ -86,14 +86,14 @@ module pinion (cp, N, width, shaft_diameter, backlash=0){
cp = (cp!=false?cp:180/diametral_pitch);

// Pitch diameter: Diameter of pitch circle.
pitch_diameter = N * cp / const_pi;
pitch_diameter = N * cp / mcad_const_pi;
pitch_radius = pitch_diameter/2;
echo ("Teeth:", N, " Pitch radius:", pitch_radius);
// Base Circle
base_radius = pitch_radius*cos(20);

// Addendum: Radial distance from pitch circle to outside circle.
addendum = cp/const_pi;
addendum = cp/mcad_const_pi;

//Outer Circle
outer_radius = pitch_radius+addendum;
Expand All @@ -104,7 +104,7 @@ module pinion (cp, N, width, shaft_diameter, backlash=0){
// Root diameter: Diameter of bottom of tooth spaces.
root_radius = pitch_radius-dedendum;

backlash_angle = backlash / pitch_radius * 180 / const_pi;
backlash_angle = backlash / pitch_radius * 180 / mcad_const_pi;
half_thick_angle = (360 / N - backlash_angle) / 4;

difference(){
Expand Down Expand Up @@ -168,7 +168,7 @@ module involute_pinion_tooth ( pitch_radius, root_radius, base_radius, outer_rad
// Finds the angle of the involute about the base radius at the given distance (radius) from it's center.
//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html

function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / const_pi;
function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / mcad_const_pi;

// Calculate the involute position for a given base radius and involute angle.

Expand All @@ -178,7 +178,7 @@ function mirror_point(coord)=[coord[0],-coord[1]];

function rotate_point(rotate,coord)=[cos(rotate)*coord[0]+sin(rotate)*coord[1],cos(rotate)*coord[1]-sin(rotate)*coord[0]];

function involute (base_radius, involute_angle)=[base_radius*(cos(involute_angle)+involute_angle*const_pi/180*sin(involute_angle)),base_radius*(sin(involute_angle)-involute_angle*const_pi/180*cos(involute_angle))];
function involute (base_radius, involute_angle)=[base_radius*(cos(involute_angle)+involute_angle*mcad_const_pi/180*sin(involute_angle)),base_radius*(sin(involute_angle)-involute_angle*mcad_const_pi/180*cos(involute_angle))];



Expand Down
22 changes: 13 additions & 9 deletions general/constants.scad
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@

// MIT license
// Author: Elmo Mäntynen

// http://oeis.org/A001113
const_e = 2.71828182845904523536028747135266249775724709369995;
mcad_const_e = 2.71828182845904523536028747135266249775724709369995;
// http://oeis.org/A000796
const_pi = 3.14159265358979323846264338327950288419716939937510;
mcad_const_pi = 3.14159265358979323846264338327950288419716939937510;
//
const_pi_div_180 = 0.01745329251994329576923690768489;
mcad_const_pi_div_180 = 0.01745329251994329576923690768489;
//
const_180_div_pi = 57.295779513082320876798154814105;
mcad_const_180_div_pi = 57.295779513082320876798154814105;
// see http://tauday.com/
const_tau = 2.0 * const_pi;
mcad_const_tau = 2.0 * mcad_const_pi;
// http://oeis.org/A001622
const_phi = 1.61803398874989484820458683436563811772030917980576;
mcad_const_phi = 1.61803398874989484820458683436563811772030917980576;
// http://oeis.org/A002193
const_sqrt2 = 1.41421356237309504880168872420969807856967187537694;
mcad_const_sqrt2 = 1.41421356237309504880168872420969807856967187537694;
// http://oeis.org/A002194
const_sqrt3 = 1.73205080756887729352744634150587236694280525381038;
mcad_const_sqrt3 = 1.73205080756887729352744634150587236694280525381038;
// http://oeis.org/A002163
const_sqrt5 = 2.23606797749978969640917366873127623544061835961152;
mcad_const_sqrt5 = 2.23606797749978969640917366873127623544061835961152;

// translates a imperial measurement in inches to meters
mcad_const_mm_per_inch = 25.4;
2 changes: 1 addition & 1 deletion general/math.scad
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include <MCAD/general/constants.scad>

function deg(angle) = 360*angle/const_tau;
function deg(angle) = 360*angle/mcad_const_tau;

// transformations.scad
// License: GNU LGPL 2.1 or later.
Expand Down
2 changes: 1 addition & 1 deletion general/utilities.scad
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function rotate_2dvector (rotate, coord) =

/********************** Circel ***************************/

function circel_area(r) = const_pi * r * r;
function circel_area(r) = mcad_const_pi * r * r;

function circel_radius3Points(a,b,c) = (distance2D(a,b) * distance2D(b,c) * distance2D(c,a)) / (4 * triangle_area3Points(a,b,c));

Expand Down
4 changes: 3 additions & 1 deletion units/default.scad
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include <MCAD/general/constants.scad>

// Default units are mm.
length_mm = 1;

// Default units are inch.
// length_mm = 1/25.4
// length_mm = 1/mcad_const_mm_per_inch // 1/25.4
4 changes: 2 additions & 2 deletions units/us.scad
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
*/

include <MCAD/units/metric.scad>

include <MCAD/general/constants.scad>
/*
* Conversion to metric is defined by Roberts, R.W. (February 3, 1975).
* Federal Register republished in Barbrow, L.E. and Judson, L. V. (1976)
* Weights and Measures of the United States. National Bureau of Standards
* Special Publication 447. p. 36
* http://physics.nist.gov/Pubs/SP447/app9.pdf
*/
length_inch = 25.4 * length_mm;
length_inch = mcad_const_mm_per_inch * length_mm;
function length_inch(quantity) = quantity * length_inch;

length_in = length_inch;
Expand Down