mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 00:45:08 +01:00
edge edge align to double edge edge implementation
This commit is contained in:
parent
ef8a57ade3
commit
02bdeba3ca
2 changed files with 18 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ import {eqTol} from "../../../brep/geom/tolerance";
|
|||
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
|
||||
import {Plane} from './../../../brep/geom/impl/plane';
|
||||
import {AssemblyDOF, ModificationResponse} from "./assemblyDOF";
|
||||
import {areEqual, clamp, DEG_RAD} from "../../../math/math";
|
||||
import {areEqual, clamp, DEG_RAD, lineLineIntersection2d, lineLineIntersection} from "../../../math/math";
|
||||
import {ConflictDOF} from "./conflictDOF";
|
||||
import {PPPPDOF} from "./PPPPDOF";
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
|
|
@ -90,13 +90,16 @@ export class EEDOF implements AssemblyDOF {
|
|||
|
||||
rot.combine(location, location);
|
||||
|
||||
|
||||
const ptFixed = constr.fixedPart.location.apply(constr.fixedEdge.favorablePoint);
|
||||
const ptMoving = constr.movingPart.location.apply(constr.movingEdge.favorablePoint);
|
||||
const ptFixed = constr.fixedPart.location.apply(constr.fixedEdge.favorablePoint);
|
||||
|
||||
const dir = ptFixed._minus(ptMoving);
|
||||
const isec1 = lineLineIntersection(this.origin, ptMoving, this.dir, vecA);
|
||||
const isec2 = lineLineIntersection(this.origin, ptFixed, this.dir, vecB);
|
||||
|
||||
// constr.movingPart.location.translateVec(dir);
|
||||
|
||||
const dir = this.dir.multiply(isec2.u1 - isec1.u1);
|
||||
|
||||
constr.movingPart.location.translateVec(dir);
|
||||
|
||||
return new EEEEDOF(this.origin, this.dir, constr.fixedEdge.favorablePoint, vecB);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,6 +300,16 @@ export function lineLineIntersection2d(p1, p2, v1, v2) {
|
|||
return [p1[0] + v1[0] * u1, p1[1] + v1[1] * u1];
|
||||
}
|
||||
|
||||
export function lineLineIntersection(p1, p2, v1, v2) {
|
||||
let zAx = v1.cross(v2);
|
||||
const n1 = zAx.cross(v1)._normalize();
|
||||
const n2 = zAx.cross(v2)._normalize();
|
||||
return {
|
||||
u1: n2.dot(p2.minus(p1)) / n2.dot(v1),
|
||||
u2: n1.dot(p1.minus(p2)) / n1.dot(v2),
|
||||
}
|
||||
}
|
||||
|
||||
export const DEG_RAD = Math.PI / 180.0;
|
||||
|
||||
export const sq = (a) => a * a;
|
||||
|
|
|
|||
Loading…
Reference in a new issue