修复:在三维坐标系下偏移错误

pull/2177/MERGE
ChenX 1 year ago
parent 0c6accae8b
commit 7774471c19

@ -50,7 +50,7 @@ Vector3 {
exports[`直线偏移 1`] = `
Vector3 {
"x": -6.123233995736766e-16,
"x": 0,
"y": 10,
"z": 0,
}
@ -58,7 +58,7 @@ Vector3 {
exports[`直线偏移 2`] = `
Vector3 {
"x": 4.999999999999999,
"x": 5,
"y": 10,
"z": 0,
}

@ -369,7 +369,7 @@ Array [
exports[`圆弧合集 8`] = `
Array [
0,
390.90041837162016,
390.9004183716206,
0,
]
`;
@ -408,8 +408,8 @@ Array [
exports[`圆弧合集 13`] = `
Array [
-0.8112557813765306,
-20.020800824495154,
-0.8112557813756212,
-20.0208008244947,
0,
]
`;
@ -417,7 +417,7 @@ Array [
exports[`圆弧合集 14`] = `
Array [
-890.6332403472697,
901.9543177434239,
901.9543177434243,
0,
]
`;
@ -425,15 +425,15 @@ Array [
exports[`圆弧合集 15`] = `
Array [
-838.0308338264754,
848.6832679602089,
848.6832679602094,
0,
]
`;
exports[`圆弧合集 16`] = `
Array [
3.020815205217332,
2.982898780776395,
3.020815205215513,
2.982898780775031,
0,
]
`;
@ -1601,7 +1601,7 @@ Array [
exports[`测试重叠墙裁剪共面墙 11`] = `
Array [
95.73217955431755,
72.35571710500767,
72.35571710500722,
0,
]
`;
@ -1744,23 +1744,23 @@ Array [
exports[`直线与圆弧 1`] = `
Array [
1729.7058390528305,
-484.8814639276738,
1729.705839052831,
-484.8814639276739,
0,
]
`;
exports[`直线与圆弧 2`] = `
Array [
1228.2620544368035,
-344.3137495380443,
1228.262054436803,
-344.3137495380442,
0,
]
`;
exports[`直线与圆弧 3`] = `
Array [
-32.39051566134185,
-32.39051566134094,
-115.54589778608533,
0,
]

@ -280,13 +280,14 @@ export function GetPointAtCurveDir(cu: Curve, pt: Vector3): number
}
else if (cu instanceof Spline)
return GetPointAtCurveDir(cu.Convert2Polyline(), pt);
//最近点
let cp = cu.GetClosestPointTo(pt, false);
if (equalv3(cp, pt, 1e-6)) return 0;
//最近点参数
let cparam = cu.GetParamAtPoint(cp);
let dri = cu.GetFistDeriv(cparam);
let cross = dri.cross(pt.clone().sub(cp)).applyMatrix4(cu.OCSInv);
//最近点的切线
let deriv = cu.GetFistDeriv(cu.GetParamAtPoint(cp));
let vec2 = pt.clone().sub(cp);
let cross = deriv.cross(vec2).applyMatrix4(cu.OCSInv.setPosition(0, 0, 0));
return -Math.sign(cross.z);
}

@ -9,6 +9,7 @@ import { Box3Ext } from '../../Geometry/Box';
import { BufferGeometryUtils } from '../../Geometry/BufferGeometryUtils';
import { AsVector2, equaln, equalv3, isParallelTo, MoveMatrix, updateGeometry } from '../../Geometry/GeUtils';
import { PlaneExt } from '../../Geometry/Plane';
import { ROTATE_MTX2 } from '../../Geometry/RotateUV';
import { IntersectEllipseAndLine, IntersectLineAndArc, IntersectLineAndCircle, IntersectLineAndLine, IntersectOption, IntersectPolylineAndCurve, IntersectResult, reverseIntersectOption } from '../../GraphicsSystem/IntersectWith';
import { RenderType } from '../../GraphicsSystem/RenderType';
import { Factory } from '../CADFactory';
@ -403,13 +404,12 @@ export class Line extends Curve
GetOffsetCurves(offsetDist: number): Array<Curve>
{
let derv = this.GetFistDeriv(0).normalize().multiplyScalar(offsetDist);
derv.applyMatrix4(new Matrix4().makeRotationAxis(this.Normal, -Math.PI / 2));
let offset = this._EndPoint.clone().sub(this._StartPoint).normalize().multiplyScalar(offsetDist);
ROTATE_MTX2.applyVector(offset);
let newLine = this.Clone() as Line;
newLine.SetStartEndPoint(
this.StartPoint.add(derv),
this.EndPoint.add(derv)
);
newLine.ClearDraw();
newLine._StartPoint.add(offset);
newLine._EndPoint.add(offset);
return [newLine];
}

Loading…
Cancel
Save