!18 圆弧和圆弧相交

Merge pull request !18 from 土川的三个金子/Database_ArcIntersectArc
pull/649615/MERGE
ChenX 7 years ago
parent 72cb7a7cce
commit b1b9ec5d53

@ -5,6 +5,7 @@ import { ColorMaterial } from '../Common/ColorPalette';
import { getArcAngle, isAtArc, Vec3DTo2D } from '../Common/CurveUtils';
import { equal, polar } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import { Intersect, IntersectArcAndArc } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { Curve } from './Curve';
@ -265,6 +266,14 @@ export class Arc extends Curve
}
}
IntersectWith(curve: Curve, intType: Intersect): Vector3[]
{
if (curve instanceof Arc)
{
return IntersectArcAndArc(this, curve, intType);
}
return [];
}
//******************** Curve function end*****************//
SetExtendPointAngle(newParam: number, allAngle: number)
@ -286,7 +295,6 @@ export class Arc extends Curve
}
}
getArcBul(param: number = 1)//圆心角
{
let ptArr = this.GetStretchPoints();
@ -378,9 +386,8 @@ export class Arc extends Curve
{
let obj = super.Draw(renderType);
if (obj) return obj;
//创建
let shape = new THREE.Shape();
//圆心x,圆心y,半径,起点角度,端点角度,时针方向
shape.absarc(this.m_Center.x, this.m_Center.y, this.m_Radius, this.m_StartAngle, this.m_EndAngle, true);
let geo = new THREE.Geometry().setFromPoints(shape.getPoints(60));
let arc = new THREE.Line(geo, ColorMaterial.GetLineMaterial(this.m_Color));
@ -398,7 +405,6 @@ export class Arc extends Curve
let shape = new THREE.Shape();
//圆心x,圆心y,半径,起点角度,端点角度,时针方向
shape.absarc(this.m_Center.x, this.m_Center.y, this.m_Radius, this.m_StartAngle, this.m_EndAngle, true);
// //调用setFromPoints()方法, 重新设置边界.
geo.setFromPoints(shape.getPoints(60));
geo.verticesNeedUpdate = true;
}

@ -13,6 +13,49 @@ export enum Intersect
ExtendArg = 2,
ExtendBoth = 3,
}
export function IntersectArcAndArc(arc1: Arc, arc2: Arc, intType: Intersect)
{
let pts: Vector3[] = [];
let dist = arc2.Center.distanceTo(arc1.Center);
if (dist > (arc1.Radius + arc2.Radius + 1e-3))
{
return pts;
}
let dstsqr = dist * dist;
let r1sqr = arc1.Radius * arc1.Radius;
let r2sqr = arc2.Radius * arc2.Radius;
let a = (dstsqr - r2sqr + r1sqr) / (2 * dist);
let h = Math.sqrt(Math.abs(r1sqr - (a * a)));
let ratio_a = a / dist;
let ratio_h = h / dist;
let dx = arc2.Center.x - arc1.Center.x;
let dy = arc2.Center.y - arc1.Center.y;
let phix = arc1.Center.x + (ratio_a * dx);
let phiy = arc1.Center.y + (ratio_a * dy);
dx = dx * ratio_h;
dy = dy * ratio_h;
let pt = new Vector3(phix + dy, phiy - dx);
let p2 = new Vector3(phix - dy, phiy + dx);
if (arc1.PtOnCurve(pt) && arc2.PtOnCurve(pt))//点在圆弧上
{
pts.push(pt);
}
if (arc1.PtOnCurve(p2) && arc2.PtOnCurve(p2) && !equal(pt, p2))//点在圆弧上&&不重复原来的点
{
pts.push(p2);
}
return pts;
}
export function IntersectLineAndArc(line: Line, arc: Arc, intType: Intersect)
{
let pts: Vector3[] = [];

Loading…
Cancel
Save