utils修改
This commit is contained in:
parent
3a87487697
commit
3cb91d10ad
@ -695,16 +695,14 @@ export function splitLineEvenly(
|
||||
});
|
||||
}
|
||||
|
||||
/** 计算折线的平行线 */
|
||||
export function getParallelOfPolyline(
|
||||
/** 计算直线的平行线 */
|
||||
export function getParallelOfLine(
|
||||
points: IPointData[],
|
||||
direction: 'L' | 'R',
|
||||
offset: number
|
||||
) {
|
||||
if (points.length < 2) throw Error('折线点不能少于2个');
|
||||
if (points.length !== 2) throw Error('直线点的个数需为2');
|
||||
const normalVecs = points.map((p, i) => {
|
||||
if (points[i - 1] && points[i + 1]) {
|
||||
} else {
|
||||
let point;
|
||||
if (points[i + 1]) {
|
||||
point = new Vector2([
|
||||
@ -721,7 +719,6 @@ export function getParallelOfPolyline(
|
||||
(direction === 'L' ? Math.PI : -Math.PI) / 2
|
||||
);
|
||||
return rotate.apply(point);
|
||||
}
|
||||
});
|
||||
return points.map((p, i) => ({
|
||||
x: p.x + offset * normalVecs[i]?.x,
|
||||
|
Loading…
Reference in New Issue
Block a user