Comparing version 0.1.6 to 0.2.0
@@ -5,14 +5,14 @@ //This example makes quick work out of a fourbar position homework | ||
var FourBar = require('../vectorFourBar.js'); | ||
var four = new FourBar; | ||
const FourBar = require('../vectorFourBar.js'); | ||
const four = new FourBar; | ||
var output; | ||
var coupler; | ||
var transmission; | ||
let output; | ||
let coupler; | ||
let transmission; | ||
var link1 = 20; | ||
var link2 = 10; | ||
var link3 = 10; | ||
var link4 = 10; | ||
const link1 = 20; | ||
const link2 = 10; | ||
const link3 = 10; | ||
const link4 = 10; | ||
angle = (75 * (Math.PI/180)); | ||
@@ -25,16 +25,8 @@ | ||
console.log(''); | ||
console.log('crossed output angle', (output.crossed * (180/Math.PI))); | ||
console.log(''); | ||
console.log('open output angle', (output.open * (180/Math.PI))); | ||
console.log(''); | ||
console.log('crossed coupler angle', (coupler.crossed * (180/Math.PI))); | ||
console.log(''); | ||
console.log('open coupler angle', (coupler.open * (180/Math.PI))); | ||
console.log(''); | ||
console.log('TYPE: ', four.linkageType(link2, link3, link4, link1, angle)); | ||
console.log(''); | ||
console.log('crossed transmission angle', (transmission.crossed * (180/Math.PI))); | ||
console.log(''); | ||
console.log('open transmission angle', (transmission.open * (180/Math.PI))); | ||
console.log(''); | ||
console.log(`Crossed output angle ${(output.crossed * (180/Math.PI))} \n`); | ||
console.log(`Open output angle ${(output.open * (180/Math.PI))} \n`); | ||
console.log(`Crossed coupler angle ${(coupler.crossed * (180/Math.PI))} \n`); | ||
console.log(`Open coupler angle, ${(coupler.open * (180/Math.PI))} \n`); | ||
console.log(`TYPE: ${four.linkageType(link2, link3, link4, link1, angle)} \n`); | ||
console.log(`Crossed transmission angle ${(transmission.crossed * (180/Math.PI))} \n`); | ||
console.log(`Open transmission angle ${(transmission.open * (180/Math.PI))} \n`); |
{ | ||
"name": "fourbar", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "FourBar linkage vector analysis by vector method", | ||
@@ -5,0 +5,0 @@ "main": "vectorFourBar.js", |
@@ -33,23 +33,31 @@ # FourBar | ||
var FourBar = require('../lib/vectorFourBar.js'); | ||
var four = new FourBar; | ||
``` javascript | ||
const FourBar = require('fourbar'); | ||
const four = new FourBar; | ||
var output; | ||
var coupler; | ||
let output; | ||
let coupler; | ||
let transmission; | ||
output = four.outputAngle(2, 7, 9, 6, 0.523599); | ||
coupler = four.couplerAngle(2, 7, 9, 6, 0.523599); | ||
const link1 = 20; | ||
const link2 = 10; | ||
const link3 = 10; | ||
const link4 = 10; | ||
angle = (75 * (Math.PI/180)); | ||
console.log(''); | ||
console.log('crossed output angle', (output.crossed * (180/Math.PI))); | ||
console.log(''); | ||
console.log('open output angle', (output.open * (180/Math.PI))); | ||
console.log(''); | ||
console.log('crossed coupler angle', (coupler.crossed * (180/Math.PI))); | ||
console.log(''); | ||
console.log('open coupler angle', (coupler.open * (180/Math.PI))); | ||
console.log(''); | ||
console.log('TYPE: ', four.linkageType(2, 7, 9, 6, 0.523599)); | ||
output = four.outputAngle(link2, link3, link4, link1, angle); | ||
coupler = four.couplerAngle(link2, link3, link4, link1, angle); | ||
transmission = four.transmissionAngle(link2, link3, link4, link1, angle); | ||
console.log(`Crossed output angle ${(output.crossed * (180/Math.PI))} \n`); | ||
console.log(`Open output angle ${(output.open * (180/Math.PI))} \n`); | ||
console.log(`Crossed coupler angle ${(coupler.crossed * (180/Math.PI))} \n`); | ||
console.log(`Open coupler angle, ${(coupler.open * (180/Math.PI))} \n`); | ||
console.log(`TYPE: ${four.linkageType(link2, link3, link4, link1, angle)} \n`); | ||
console.log(`Crossed transmission angle ${(transmission.crossed * (180/Math.PI))} \n`); | ||
console.log(`Open transmission angle ${(transmission.open * (180/Math.PI))} \n`); | ||
``` |
@@ -0,338 +1,293 @@ | ||
'use strict'; | ||
//Mario Solorzano | ||
//ME 415 Kinematics | ||
//October 2015 | ||
class VectorFourBar{ | ||
constructor(){ | ||
this.type = 'VectorMethod'; | ||
var constants = { | ||
K1: 0, | ||
K2: 0, | ||
K3: 0, | ||
K4: 0, | ||
K5: 0, | ||
A: 0, | ||
B: 0, | ||
C: 0, | ||
D: 0, | ||
E: 0, | ||
F: 0 | ||
} | ||
this.constants = { | ||
K1: 0, | ||
K2: 0, | ||
K3: 0, | ||
K4: 0, | ||
K5: 0, | ||
A: 0, | ||
B: 0, | ||
C: 0, | ||
D: 0, | ||
E: 0, | ||
F: 0 | ||
} | ||
var linkage = { | ||
input: '', | ||
coupler: '', | ||
output: '', | ||
ground: '', | ||
thetaTwo: '', | ||
thetaThree: {}, | ||
thetaFour: {}, | ||
vectorInput:{}, | ||
vectorCoupler:{ | ||
open: {}, | ||
crossed: {}, | ||
}, | ||
vectorOutput:{ | ||
open: {}, | ||
crossed: {} | ||
} | ||
} | ||
function VectorFourBar(){ | ||
Object.defineProperties( | ||
this, | ||
{ | ||
type:{ | ||
enumerable:true, | ||
writable:false, | ||
value:'VectorMethod' | ||
this.linkage = { | ||
input: '', | ||
coupler: '', | ||
output: '', | ||
ground: '', | ||
thetaTwo: '', | ||
thetaThree: {}, | ||
thetaFour: {}, | ||
vectorInput:{}, | ||
vectorCoupler:{ | ||
open: {}, | ||
crossed: {}, | ||
}, | ||
linkageType:{ | ||
enumerable:true, | ||
writable:false, | ||
value:getLinkageType | ||
}, | ||
couplerAngle:{ | ||
enumerable:true, | ||
writable:false, | ||
value:getCouplerAngle | ||
}, | ||
outputAngle:{ | ||
enumerable:true, | ||
writable:false, | ||
value:getOutputAngle | ||
}, | ||
inputVector:{ | ||
enumerable:true, | ||
writable:false, | ||
value:getInputVector | ||
}, | ||
couplerVector:{ | ||
enumerable:true, | ||
writable:false, | ||
value:getCouplerVector | ||
}, | ||
outputVector:{ | ||
enumerable:true, | ||
writable:false, | ||
value:getOutputVector | ||
}, | ||
transmissionAngle:{ | ||
enumerable:true, | ||
writable: false, | ||
value:getTransmissionAngle | ||
vectorOutput:{ | ||
open: {}, | ||
crossed: {} | ||
} | ||
} | ||
); | ||
} | ||
} | ||
function getInputVector(input,coupler,output,ground,thetaTwo, delta){ | ||
linkageType(input,coupler,output,ground){ | ||
let temp; | ||
let swap = true; | ||
let tempArray = []; | ||
let j = 0; | ||
if(!delta){ | ||
delta = 0; | ||
} | ||
const LINKS = 4; | ||
getCouplerAngle(input,coupler,output,ground,thetaTwo); | ||
for (let i = 0; i < LINKS; i++ ){ | ||
tempArray[i] = arguments[i]; | ||
} | ||
if(typeof(linkage.thetaThree) == 'string' ){ | ||
return 'Not a Possible Configuration'; | ||
} | ||
while(swap == true){ | ||
swap = false; | ||
j++; | ||
for (let i = 0; i < tempArray.length - j; i++){ | ||
if(tempArray[i] > tempArray[i+1]){ | ||
temp = tempArray[i]; | ||
tempArray[i] = tempArray[i+1]; | ||
tempArray[i+1] = temp; | ||
swapped = true | ||
} | ||
} | ||
} | ||
linkage.vectorInput.Re = (input * (Math.cos(thetaTwo + delta))); | ||
linkage.vectorInput.Im = (input * (Math.sin(thetaTwo + delta))); | ||
let setup = { | ||
S : tempArray[0], | ||
L : tempArray[3], | ||
Q : tempArray[1], | ||
P : tempArray[2] | ||
} | ||
return linkage.vectorInput; | ||
} | ||
let cases = { | ||
one: ((setup.S + setup.L) < (setup.P + setup.Q)), | ||
two: ((setup.S + setup.L) > (setup.P + setup.Q)), | ||
three: ((setup.S + setup.L) == (setup.P + setup.Q)) | ||
} | ||
function getCouplerVector(input,coupler,output,ground,thetaTwo, delta){ | ||
let general; | ||
if(!delta){ | ||
delta = 0; | ||
} | ||
if (cases.one){ | ||
general = 'Case I'; | ||
}else if (cases.two){ | ||
general = 'Case II'; | ||
}else if (cases.three) { | ||
general = 'Case III'; | ||
} | ||
getCouplerAngle(input,coupler,output,ground,thetaTwo); | ||
if(typeof(linkage.thetaThree) == 'string' ){ | ||
return 'Not a Possible Configuration'; | ||
if(cases.one && (setup.S == ground)){ | ||
return 'Grashof Crank-Crank-Crank'; | ||
}else if (cases.three && (setup.S == setup.L && setup.L == setup.P && setup.P ==setup.Q)) { | ||
return 'Tripple Change Point'; | ||
}else if (cases.three && (setup.S == setup.L || setup.S == setup.P || setup.S == setup.Q || setup.L == setup.Q || setup.L == setup.P || setup.Q == setup.P)) { | ||
return 'Double Change Point'; | ||
}else if(cases.one && (setup.S == input)){ | ||
return 'Grashof Crank-Rocker-Rocker'; | ||
}else if(cases.one && (setup.S == coupler)){ | ||
return 'Grashof Rocker-Crank-Rocker'; | ||
}else if(cases.one && (setup.S == output)){ | ||
return 'Grashof Rocker-Rocker-Crank'; | ||
}else if(cases.two && (setup.L == ground)){ | ||
return 'Class 1 Rocker-Rocker-Rocker'; | ||
}else if (cases.two && (setup.L == input)) { | ||
return 'Class 2 Rocker-Rocker-Rocker'; | ||
}else if (cases.two && (setup.L == coupler)) { | ||
return 'Class 3 Rocker-Rocker-Rocker'; | ||
}else if (cases.two && (setup.L == output) ) { | ||
return 'Class 4 Rocker-Rocker-Rocker'; | ||
}else if (cases.three && (setup.S == ground)) { | ||
return 'Change Point Crank-Crank-Crank'; | ||
}else if (cases.three && (setup.S == input)) { | ||
return 'Change Point Crank-Rocker-Rocker'; | ||
}else if (cases.three && (setup.S == coupler)) { | ||
return 'Change Point Rocker-Crank-Rocker'; | ||
}else if (cases.three && (setup.S == output)) { | ||
return 'Change Point Rocker-Rocker-Crank'; | ||
}else { | ||
return(`Not Part of Barker's 14 ${general}`); | ||
} | ||
} | ||
linkage.vectorCoupler.open.Re = (coupler * (Math.cos(linkage.thetaThree.open + delta))); | ||
linkage.vectorCoupler.open.Im = (coupler * (Math.sin(linkage.thetaThree.open + delta))); | ||
couplerAngle(input,coupler,output,ground,thetaTwo){ | ||
let temp = Object.keys(this.linkage); | ||
for(let i in arguments){ | ||
this.linkage[temp[i]] = arguments[i]; | ||
} | ||
linkage.vectorCoupler.crossed.Re = (coupler * (Math.cos(linkage.thetaThree.crossed + delta))); | ||
linkage.vectorCoupler.crossed.Im = (coupler * (Math.sin(linkage.thetaThree.crossed + delta))); | ||
if(!this.errorCheck()){ | ||
return; | ||
} | ||
return linkage.vectorCoupler; | ||
} | ||
this.getConstantsK(); | ||
this.getConstantsTierD(); | ||
function getOutputVector(input,coupler,output,ground,thetaTwo, delta){ | ||
this.linkage.thetaThree = this.modQuadratic(this.constants.D, this.constants.E, this.constants.F); | ||
if(!delta){ | ||
delta = 0; | ||
return this.linkage.thetaThree; | ||
} | ||
getOutputAngle(input,coupler,output,ground,thetaTwo); | ||
outputAngle(input,coupler,output,ground,thetaTwo){ | ||
let temp = Object.keys(this.linkage); | ||
for(let i in arguments){ | ||
this.linkage[temp[i]] = arguments[i]; | ||
} | ||
if(typeof(linkage.thetaFour) == 'string' ){ | ||
return 'Not a Possible Configuration'; | ||
} | ||
if(!this.errorCheck(this.linkage)){ | ||
return; | ||
} | ||
linkage.vectorOutput.open.Re = (coupler * (Math.cos(linkage.thetaFour.open + delta))); | ||
linkage.vectorOutput.open.Im = (coupler * (Math.sin(linkage.thetaFour.open + delta))); | ||
this.getConstantsK(this.linkage); | ||
this.getConstantsTierA(this.linkage); | ||
linkage.vectorOutput.crossed.Re = (coupler * (Math.cos(linkage.thetaFour.crossed + delta))); | ||
linkage.vectorOutput.crossed.Im = (coupler * (Math.sin(linkage.thetaFour.crossed + delta))); | ||
this.linkage.thetaFour = this.modQuadratic(this.constants.A, this.constants.B, this.constants.C); | ||
return linkage.vectorOutput; | ||
} | ||
return this.linkage.thetaFour; | ||
} | ||
inputVector(input,coupler,output,ground,thetaTwo, delta){ | ||
if(!delta){ | ||
delta = 0; | ||
} | ||
function getLinkageType(input,coupler,output,ground){ | ||
var temp; | ||
var swap = true; | ||
var tempArray = []; | ||
var j = 0; | ||
this.getCouplerAngle(input,coupler,output,ground,thetaTwo); | ||
const LINKS = 4; | ||
if(typeof(this.linkage.thetaThree) == 'string' ){ | ||
return 'Not a Possible Configuration'; | ||
} | ||
for (var i = 0; i < LINKS; i++ ){ | ||
tempArray[i] = arguments[i]; | ||
this.linkage.vectorInput.Re = (input * (Math.cos(thetaTwo + delta))); | ||
this.linkage.vectorInput.Im = (input * (Math.sin(thetaTwo + delta))); | ||
return this.linkage.vectorInput; | ||
} | ||
while(swap == true){ | ||
swap = false; | ||
j++; | ||
for (var i = 0; i < tempArray.length - j; i++){ | ||
if(tempArray[i] > tempArray[i+1]){ | ||
temp = tempArray[i]; | ||
tempArray[i] = tempArray[i+1]; | ||
tempArray[i+1] = temp; | ||
swapped = true | ||
} | ||
couplerVector(input,coupler,output,ground,thetaTwo, delta){ | ||
if(!delta){ | ||
delta = 0; | ||
} | ||
} | ||
var setup = { | ||
S : tempArray[0], | ||
L : tempArray[3], | ||
Q : tempArray[1], | ||
P : tempArray[2] | ||
} | ||
this.getCouplerAngle(input,coupler,output,ground,thetaTwo); | ||
var cases = { | ||
one: ((setup.S + setup.L) < (setup.P + setup.Q)), | ||
two: ((setup.S + setup.L) > (setup.P + setup.Q)), | ||
three: ((setup.S + setup.L) == (setup.P + setup.Q)) | ||
} | ||
if(typeof(this.linkage.thetaThree) == 'string' ){ | ||
return 'Not a Possible Configuration'; | ||
} | ||
var general; | ||
this.linkage.vectorCoupler.open.Re = (coupler * (Math.cos(this.linkage.thetaThree.open + delta))); | ||
this.linkage.vectorCoupler.open.Im = (coupler * (Math.sin(this.linkage.thetaThree.open + delta))); | ||
if (cases.one){ | ||
general = 'Case I'; | ||
}else if (cases.two){ | ||
general = 'Case II'; | ||
}else if (cases.three) { | ||
general = 'Case III'; | ||
} | ||
this.linkage.vectorCoupler.crossed.Re = (coupler * (Math.cos(this.linkage.thetaThree.crossed + delta))); | ||
this.linkage.vectorCoupler.crossed.Im = (coupler * (Math.sin(this.linkage.thetaThree.crossed + delta))); | ||
if(cases.one && (setup.S == ground)){ | ||
return 'Grashof Crank-Crank-Crank'; | ||
}else if (cases.three && (setup.S == setup.L && setup.L == setup.P && setup.P ==setup.Q)) { | ||
return 'Tripple Change Point'; | ||
}else if (cases.three && (setup.S == setup.L || setup.S == setup.P || setup.S == setup.Q || setup.L == setup.Q || setup.L == setup.P || setup.Q == setup.P)) { | ||
return 'Double Change Point'; | ||
}else if(cases.one && (setup.S == input)){ | ||
return 'Grashof Crank-Rocker-Rocker'; | ||
}else if(cases.one && (setup.S == coupler)){ | ||
return 'Grashof Rocker-Crank-Rocker'; | ||
}else if(cases.one && (setup.S == output)){ | ||
return 'Grashof Rocker-Rocker-Crank'; | ||
}else if(cases.two && (setup.L == ground)){ | ||
return 'Class 1 Rocker-Rocker-Rocker'; | ||
}else if (cases.two && (setup.L == input)) { | ||
return 'Class 2 Rocker-Rocker-Rocker'; | ||
}else if (cases.two && (setup.L == coupler)) { | ||
return 'Class 3 Rocker-Rocker-Rocker'; | ||
}else if (cases.two && (setup.L == output) ) { | ||
return 'Class 4 Rocker-Rocker-Rocker'; | ||
}else if (cases.three && (setup.S == ground)) { | ||
return 'Change Point Crank-Crank-Crank'; | ||
}else if (cases.three && (setup.S == input)) { | ||
return 'Change Point Crank-Rocker-Rocker'; | ||
}else if (cases.three && (setup.S == coupler)) { | ||
return 'Change Point Rocker-Crank-Rocker'; | ||
}else if (cases.three && (setup.S == output)) { | ||
return 'Change Point Rocker-Rocker-Crank'; | ||
}else { | ||
return("Not Part of Barker's 14 " + general); | ||
return this.linkage.vectorCoupler; | ||
} | ||
} | ||
outputVector(input,coupler,output,ground,thetaTwo, delta){ | ||
function getCouplerAngle(input,coupler,output,ground,thetaTwo){ | ||
var temp = Object.keys(linkage); | ||
for(var i in arguments){ | ||
linkage[temp[i]] = arguments[i]; | ||
} | ||
if(!delta){ | ||
delta = 0; | ||
} | ||
if(!errorCheck(linkage)){ | ||
return; | ||
} | ||
this.outputAngle(input,coupler,output,ground,thetaTwo); | ||
getConstantsK(linkage); | ||
getConstantsTierD(linkage); | ||
if(typeof(this.linkage.thetaFour) == 'string' ){ | ||
return 'Not a Possible Configuration'; | ||
} | ||
linkage.thetaThree = modQuadratic(constants.D, constants.E, constants.F); | ||
this.linkage.vectorOutput.open.Re = (coupler * (Math.cos(this.linkage.thetaFour.open + delta))); | ||
this.linkage.vectorOutput.open.Im = (coupler * (Math.sin(this.linkage.thetaFour.open + delta))); | ||
return linkage.thetaThree; | ||
} | ||
this.linkage.vectorOutput.crossed.Re = (coupler * (Math.cos(this.linkage.thetaFour.crossed + delta))); | ||
this.linkage.vectorOutput.crossed.Im = (coupler * (Math.sin(this.linkage.thetaFour.crossed + delta))); | ||
function getOutputAngle(input,coupler,output,ground,thetaTwo){ | ||
var temp = Object.keys(linkage); | ||
for(var i in arguments){ | ||
linkage[temp[i]] = arguments[i]; | ||
return this.linkage.vectorOutput; | ||
} | ||
if(!errorCheck(linkage)){ | ||
return; | ||
} | ||
transmissionAngle(input,coupler,output,ground,thetaTwo){ | ||
this.couplerAngle(input,coupler,output,ground,thetaTwo); | ||
this.outputAngle(input,coupler,output,ground,thetaTwo); | ||
getConstantsK(linkage); | ||
getConstantsTierA(linkage); | ||
let transmissionAngles = {}; | ||
linkage.thetaFour = modQuadratic(constants.A, constants.B, constants.C); | ||
if((typeof(this.linkage.thetaThree) != 'string') && (typeof(this.linkage.thetaFour) != 'string')){ | ||
transmissionAngles.open = Math.abs(this.linkage.thetaThree.open - this.linkage.thetaFour.open); | ||
transmissionAngles.crossed = Math.abs(this.linkage.thetaThree.crossed - this.linkage.thetaFour.crossed); | ||
return linkage.thetaFour; | ||
} | ||
if(transmissionAngles.open > (Math.PI/2)){ | ||
transmissionAngles.open = (Math.PI - transmissionAngles.open); | ||
} | ||
function getConstantsK(linkage){ | ||
constants.K1 = (linkage.ground/linkage.input); | ||
constants.K2 = (linkage.ground/linkage.output); | ||
constants.K3 = ((Math.pow(linkage.input,2)-Math.pow(linkage.coupler,2) + Math.pow(linkage.output,2) + Math.pow(linkage.ground,2))/(2*linkage.input*linkage.output)); | ||
constants.K4 = (linkage.ground/linkage.coupler); | ||
constants.K5 = ((Math.pow(linkage.output,2)-Math.pow(linkage.ground,2) - Math.pow(linkage.input,2) - Math.pow(linkage.coupler,2))/( 2 * linkage.input * linkage.coupler)); | ||
} | ||
if(transmissionAngles.crossed > (Math.PI/2)){ | ||
transmissionAngles.crossed = (Math.PI - transmissionAngles.crossed); | ||
} | ||
function getConstantsTierA(linkage){ | ||
constants.A = ( Math.cos(linkage.thetaTwo) - (constants.K1) - (constants.K2 * Math.cos(linkage.thetaTwo)) + (constants.K3)); // Radians | ||
constants.B = (-2 * Math.sin(linkage.thetaTwo)); | ||
constants.C = (constants.K1 - ((constants.K2 + 1) * Math.cos(linkage.thetaTwo)) + constants.K3); | ||
} | ||
return transmissionAngles; | ||
function getConstantsTierD(linkage){ | ||
constants.D = ( Math.cos(linkage.thetaTwo) - (constants.K1) + (constants.K4 * Math.cos(linkage.thetaTwo)) + (constants.K5)); // Radians | ||
constants.E = (-2 * Math.sin(linkage.thetaTwo)); | ||
constants.F = (constants.K1 + ((constants.K4 - 1) * Math.cos(linkage.thetaTwo)) + constants.K5); | ||
} | ||
}else{ | ||
return 'invalid linkage'; | ||
} | ||
} | ||
function modQuadratic(A,B,C){ | ||
if( Math.pow(B,2) - (4 * A * C) < 0){ | ||
return 'Not a Possible Configuration'; | ||
getConstantsK(){ | ||
this.constants.K1 = (this.linkage.ground/this.linkage.input); | ||
this.constants.K2 = (this.linkage.ground/this.linkage.output); | ||
this.constants.K3 = ((Math.pow(this.linkage.input,2)-Math.pow(this.linkage.coupler,2) + Math.pow(this.linkage.output,2) + Math.pow(this.linkage.ground,2))/(2*this.linkage.input*this.linkage.output)); | ||
this.constants.K4 = (this.linkage.ground/this.linkage.coupler); | ||
this.constants.K5 = ((Math.pow(this.linkage.output,2)-Math.pow(this.linkage.ground,2) - Math.pow(this.linkage.input,2) - Math.pow(this.linkage.coupler,2))/( 2 * this.linkage.input * this.linkage.coupler)); | ||
} | ||
var temp = {}; | ||
temp.crossed = (2 * Math.atan((-B + Math.sqrt( Math.pow(B,2) - (4 * A * C) ))/( 2 * A))); | ||
temp.open = (2* Math.atan((-B - Math.sqrt( Math.pow(B,2) - (4 * A * C) ))/( 2 * A))); | ||
getConstantsTierA(){ | ||
this.constants.A = ( Math.cos(this.linkage.thetaTwo) - (this.constants.K1) - (this.constants.K2 * Math.cos(this.linkage.thetaTwo)) + (this.constants.K3)); // Radians | ||
this.constants.B = (-2 * Math.sin(this.linkage.thetaTwo)); | ||
this.constants.C = (this.constants.K1 - ((this.constants.K2 + 1) * Math.cos(this.linkage.thetaTwo)) + this.constants.K3); | ||
} | ||
return temp; | ||
} | ||
getConstantsTierD(){ | ||
this.constants.D = ( Math.cos(this.linkage.thetaTwo) - (this.constants.K1) + (this.constants.K4 * Math.cos(this.linkage.thetaTwo)) + (this.constants.K5)); // Radians | ||
this.constants.E = (-2 * Math.sin(this.linkage.thetaTwo)); | ||
this.constants.F = (this.constants.K1 + ((this.constants.K4 - 1) * Math.cos(this.linkage.thetaTwo)) + this.constants.K5); | ||
} | ||
function getTransmissionAngle(input,coupler,output,ground,thetaTwo){ | ||
getCouplerAngle(input,coupler,output,ground,thetaTwo); | ||
getOutputAngle(input,coupler,output,ground,thetaTwo); | ||
var transmissionAngles = {}; | ||
if((typeof(linkage.thetaThree) != 'string') && (typeof(linkage.thetaFour) != 'string')){ | ||
transmissionAngles.open = Math.abs(linkage.thetaThree.open - linkage.thetaFour.open); | ||
transmissionAngles.crossed = Math.abs(linkage.thetaThree.crossed - linkage.thetaFour.crossed); | ||
if(transmissionAngles.open > (Math.PI/2)){ | ||
transmissionAngles.open = (Math.PI - transmissionAngles.open); | ||
modQuadratic(A,B,C){ | ||
if( Math.pow(B,2) - (4 * A * C) < 0){ | ||
return 'Not a Possible Configuration'; | ||
} | ||
if(transmissionAngles.crossed > (Math.PI/2)){ | ||
transmissionAngles.crossed = (Math.PI - transmissionAngles.crossed); | ||
} | ||
var temp = {}; | ||
temp.crossed = (2 * Math.atan((-B + Math.sqrt( Math.pow(B,2) - (4 * A * C) ))/( 2 * A))); | ||
temp.open = (2* Math.atan((-B - Math.sqrt( Math.pow(B,2) - (4 * A * C) ))/( 2 * A))); | ||
return transmissionAngles; | ||
}else{ | ||
return 'invalid linkage'; | ||
return temp; | ||
} | ||
} | ||
function errorCheck(linkage){ | ||
errorCheck(){ | ||
if (!linkage.input || !linkage.coupler || !linkage.output || !linkage.ground || !linkage.thetaTwo){ | ||
console.log('Must Provide Linkage Lengths and Input Angle for a Solution'); | ||
return false; | ||
}else if( | ||
typeof(linkage.input) !== 'number' | ||
||typeof(linkage.coupler) !== 'number' | ||
||typeof(linkage.output) !== 'number' | ||
||typeof(linkage.ground) !== 'number' | ||
||typeof(linkage.thetaTwo) !== 'number' | ||
){ | ||
console.log('Incorrect Parameter Type'); | ||
return false; | ||
}else { | ||
return true; | ||
if (!this.linkage.input || !this.linkage.coupler || !this.linkage.output || !this.linkage.ground || !this.linkage.thetaTwo){ | ||
console.log('Must Provide Linkage Lengths and Input Angle for a Solution'); | ||
return false; | ||
}else if( | ||
typeof(this.linkage.input) !== 'number' | ||
||typeof(this.linkage.coupler) !== 'number' | ||
||typeof(this.linkage.output) !== 'number' | ||
||typeof(this.linkage.ground) !== 'number' | ||
||typeof(this.linkage.thetaTwo) !== 'number' | ||
){ | ||
console.log('Incorrect Parameter Type'); | ||
return false; | ||
}else { | ||
return true; | ||
} | ||
} | ||
@@ -339,0 +294,0 @@ } |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18677
63
263
1