mirror of https://gitee.com/cf-fz/WebCAD.git
parent
2499ed05e2
commit
5c69b64461
@ -0,0 +1,18 @@
|
||||
import { GeUtils } from "../../src/Geometry/GeUtils";
|
||||
|
||||
test("GeUtils.angle", () =>
|
||||
{
|
||||
let pi2 = Math.PI * 0.5;
|
||||
let pi4 = pi2 * 0.5;
|
||||
|
||||
console.log(GeUtils.fixAngle(0.05, pi2, 0.1)/*?*/ == 0);
|
||||
|
||||
console.log(GeUtils.fixAngle(0.08, pi2, 0.1)/*?*/ == 0);
|
||||
console.log(GeUtils.fixAngle(0.09, pi2, 0.1)/*?*/ == 0);
|
||||
console.log(GeUtils.fixAngle(-0.05, pi2, 0.1)/*?*/ == Math.PI * 2);
|
||||
|
||||
console.log(GeUtils.fixAngle(Math.PI / 2 + 0.01, pi2, 0.1)/*?*/ == Math.PI / 2);
|
||||
|
||||
console.log(GeUtils.fixAngle(0.3, pi2));
|
||||
})
|
||||
|
@ -1,67 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
import { GeUtils } from "../src/Geometry/GeUtils"
|
||||
|
||||
let v = new THREE.Vector3(1, 0, 0);
|
||||
|
||||
let v2 = new THREE.Vector3(1, 0.1, 0)
|
||||
|
||||
|
||||
let an = v.angleTo(v2);
|
||||
|
||||
console.log('an: ', an);
|
||||
|
||||
|
||||
|
||||
console.log(an);
|
||||
|
||||
console.log(v.angleTo(v2));
|
||||
|
||||
console.log(Math.PI * 0.25);
|
||||
|
||||
|
||||
console.log(v);
|
||||
console.log(v2);
|
||||
|
||||
console.log(v.dot(v2));
|
||||
|
||||
function fixAngle(an)
|
||||
{
|
||||
let pi4 = Math.PI * 0.5;
|
||||
let rem = an % pi4;
|
||||
if (rem < 0.1)
|
||||
{
|
||||
an -= rem;
|
||||
}
|
||||
else
|
||||
{
|
||||
an += 0.2;
|
||||
rem = an % pi4;
|
||||
if (rem < 0.1)
|
||||
{
|
||||
an -= rem;
|
||||
}
|
||||
else
|
||||
{
|
||||
an -= 0.2
|
||||
}
|
||||
}
|
||||
return an;
|
||||
}
|
||||
|
||||
an = fixAngle(an);
|
||||
|
||||
console.log(an);
|
||||
|
||||
GeUtils.angle(v, an, 1);
|
||||
|
||||
console.log(v);
|
||||
|
||||
console.log(fixAngle(Math.PI / 2 + 0.0));
|
||||
console.log(fixAngle(Math.PI / 2 + 0.05));
|
||||
|
||||
console.log(Math.PI % Math.PI);
|
||||
|
||||
|
||||
|
||||
console.log(fixAngle(Math.PI / 2 + 0.05) % Math.PI / 2);
|
Loading…
Reference in new issue