Knowing trig math is not flawless at certain limits.
Like the sine of a very small angle usually is not that good.
What follows I still find unacceptable:
Code: Select all
var ori = 0
var sinOri = Math.sin(deg2rad(ori));
var cosOri = Math.cos(deg2rad(ori));
var tanOri = Math.tan(deg2rad(ori));
debugger;
ori = 45
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));
tanOri = Math.tan(deg2rad(ori));// IS NOT 1
var flaw = 1-Math.tan(deg2rad(ori));//flaw =1.1E-17
debugger;
ori = 90
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));// IS NOT 0 flaw =6.1E-17
tanOri = Math.tan(deg2rad(ori));// IS NOT N/A is huge
debugger;
ori = 135
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));
tanOri = Math.tan(deg2rad(ori));// IS NOT -1
var flaw = 1+Math.tan(deg2rad(ori));//flaw =-2.2E-16
debugger;
ori = 180
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));// IS NOT 0 flaw =1.2E-16
tanOri = Math.tan(deg2rad(ori));// IS NOT 0 flaw =-1.2E-16
debugger;
ori = 225
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));
tanOri = Math.tan(deg2rad(ori));// IS NOT 1
var flaw = 1-Math.tan(deg2rad(ori));//flaw =3.3E-16
debugger;
ori = 270
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));// IS NOT 0 flaw =-1.8E-16
tanOri = Math.tan(deg2rad(ori));// IS NOT N/A is huge
debugger;
ori = 315
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));
tanOri = Math.tan(deg2rad(ori));// IS NOT -1
var flaw = 1+Math.tan(deg2rad(ori));//flaw flaw =-4.4E-16
debugger;
ori = 360
sinOri = Math.sin(deg2rad(ori));
cosOri = Math.cos(deg2rad(ori));// IS NOT 0 flaw =-2.4E-16
tanOri = Math.tan(deg2rad(ori));// IS NOT 0 flaw =-2.4E-16
debugger;
The only option I have is to round trigs to 15 digits or to catch these flaws every use of a trig function.
Regards,
CVH