|
@@ -48,12 +48,13 @@ function drawEmpty(board: Board, text: string, pal: ChartPalette): void {
|
|
|
|
|
|
|
|
export function drawDiagram(
|
|
export function drawDiagram(
|
|
|
board: Board,
|
|
board: Board,
|
|
|
- p: SpeakerParams & { maxD?: number; maxZ?: number },
|
|
|
|
|
|
|
+ p: SpeakerParams & { maxD?: number; maxZ?: number; isSymmetric?: boolean },
|
|
|
result: CalcResult | null,
|
|
result: CalcResult | null,
|
|
|
labels: DiagramChartLabels,
|
|
labels: DiagramChartLabels,
|
|
|
pal: ChartPalette
|
|
pal: ChartPalette
|
|
|
): void {
|
|
): void {
|
|
|
const { z, d1, d2, d3, angle, hCov, vCov, dir } = p
|
|
const { z, d1, d2, d3, angle, hCov, vCov, dir } = p
|
|
|
|
|
+ const isSymmetric = p.isSymmetric === true
|
|
|
const cov = dir === 'H' ? hCov : vCov
|
|
const cov = dir === 'H' ? hCov : vCov
|
|
|
const t6 = cov / 2
|
|
const t6 = cov / 2
|
|
|
|
|
|
|
@@ -70,30 +71,25 @@ export function drawDiagram(
|
|
|
const upperAngle = aRad + t6Rad
|
|
const upperAngle = aRad + t6Rad
|
|
|
const lowerAngle = aRad - t6Rad
|
|
const lowerAngle = aRad - t6Rad
|
|
|
|
|
|
|
|
- // 覆盖角边界与前方地面(x > 0)的交点:
|
|
|
|
|
- // - 较小的边界角(越接近水平 0°)-> 交点越远(dFar / 远点)
|
|
|
|
|
- // - 较大的边界角(越接近垂直 90°)-> 交点越近(dNear / 近点)
|
|
|
|
|
- // 当边界角 <= 0°(水平或向上):不与前方地面相交,远点视为无穷远(截断到 maxD)
|
|
|
|
|
- // 当边界角 >= 90°(垂直或向上):交点在 x = 0(扬声器正下方)
|
|
|
|
|
-
|
|
|
|
|
- // 近点:较大边界角 upperAngle 决定(越垂直越近)
|
|
|
|
|
- // upperAngle >= 90°:垂直向下,交点在 x = 0(扬声器正下方)
|
|
|
|
|
- // 0° < upperAngle < 90°:正常计算 z / tan(upperAngle)
|
|
|
|
|
- // upperAngle <= 0°:不与前方地面交,nearX 为 null
|
|
|
|
|
|
|
+ // 右侧边界与地面的交点
|
|
|
let nearX: number | null = null
|
|
let nearX: number | null = null
|
|
|
if (upperAngle > 0.01 && upperAngle < Math.PI / 2 - 0.01) {
|
|
if (upperAngle > 0.01 && upperAngle < Math.PI / 2 - 0.01) {
|
|
|
nearX = Math.min(maxD, Math.max(0, z / Math.tan(upperAngle)))
|
|
nearX = Math.min(maxD, Math.max(0, z / Math.tan(upperAngle)))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 远点:较小边界角 lowerAngle 决定(越水平越远)
|
|
|
|
|
- // 0° < lowerAngle < 90°:正常计算 z / tan(lowerAngle)
|
|
|
|
|
- // lowerAngle <= 0°:下边界向上或水平,无前方交点,farX 为 null(不画虚线)
|
|
|
|
|
- // lowerAngle >= 90°:垂直向上,farX 为 null
|
|
|
|
|
let farX: number | null = null
|
|
let farX: number | null = null
|
|
|
if (lowerAngle > 0.01 && lowerAngle < Math.PI / 2 - 0.01) {
|
|
if (lowerAngle > 0.01 && lowerAngle < Math.PI / 2 - 0.01) {
|
|
|
farX = Math.min(maxD, z / Math.tan(lowerAngle))
|
|
farX = Math.min(maxD, z / Math.tan(lowerAngle))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 左侧边界与地面的交点(镜像对称)
|
|
|
|
|
+ let leftNearX: number | null = null
|
|
|
|
|
+ let leftFarX: number | null = null
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ leftNearX = nearX !== null ? -nearX : null
|
|
|
|
|
+ leftFarX = farX !== null ? -farX : null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
board.suspendUpdate()
|
|
board.suspendUpdate()
|
|
|
try {
|
|
try {
|
|
|
if (currentObjects.length > 0) {
|
|
if (currentObjects.length > 0) {
|
|
@@ -105,7 +101,6 @@ export function drawDiagram(
|
|
|
if (type === 'point') {
|
|
if (type === 'point') {
|
|
|
attrs.withLabel = false
|
|
attrs.withLabel = false
|
|
|
}
|
|
}
|
|
|
- // 核心修复:强制所有图元锁死,禁止拖拽和悬停交互
|
|
|
|
|
attrs.fixed = true
|
|
attrs.fixed = true
|
|
|
attrs.highlight = false
|
|
attrs.highlight = false
|
|
|
attrs.showInfobox = false
|
|
attrs.showInfobox = false
|
|
@@ -121,6 +116,7 @@ export function drawDiagram(
|
|
|
const gD = nice(maxD / 6)
|
|
const gD = nice(maxD / 6)
|
|
|
const gZ = nice(maxZ / 5)
|
|
const gZ = nice(maxZ / 5)
|
|
|
|
|
|
|
|
|
|
+ // 垂向网格线
|
|
|
for (let d = gD; d < maxD; d += gD) {
|
|
for (let d = gD; d < maxD; d += gD) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -130,18 +126,31 @@ export function drawDiagram(
|
|
|
],
|
|
],
|
|
|
{ strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
|
|
{ strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
|
|
|
)
|
|
)
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'segment',
|
|
|
|
|
+ [
|
|
|
|
|
+ [-d, 0],
|
|
|
|
|
+ [-d, maxZ]
|
|
|
|
|
+ ],
|
|
|
|
|
+ { strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 水平网格线
|
|
|
for (let h = gZ; h < maxZ; h += gZ) {
|
|
for (let h = gZ; h < maxZ; h += gZ) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
- [0, h],
|
|
|
|
|
|
|
+ [isSymmetric ? -maxD : 0, h],
|
|
|
[maxD, h]
|
|
[maxD, h]
|
|
|
],
|
|
],
|
|
|
{ strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
|
|
{ strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Y 轴与 X 轴
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
@@ -153,7 +162,7 @@ export function drawDiagram(
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
- [0, 0],
|
|
|
|
|
|
|
+ [isSymmetric ? -maxD : 0, 0],
|
|
|
[maxD, 0]
|
|
[maxD, 0]
|
|
|
],
|
|
],
|
|
|
{ strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
|
|
{ strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
|
|
@@ -176,6 +185,23 @@ export function drawDiagram(
|
|
|
anchorY: 'top',
|
|
anchorY: 'top',
|
|
|
layer: 1
|
|
layer: 1
|
|
|
})
|
|
})
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'segment',
|
|
|
|
|
+ [
|
|
|
|
|
+ [-d, 0],
|
|
|
|
|
+ [-d, -maxZ * 0.015]
|
|
|
|
|
+ ],
|
|
|
|
|
+ { strokeColor: pal.dim, strokeWidth: 1, layer: 1 }
|
|
|
|
|
+ )
|
|
|
|
|
+ addObj('text', [-d, -maxZ * 0.03, d.toFixed(0)], {
|
|
|
|
|
+ fontSize: 9,
|
|
|
|
|
+ color: pal.dim,
|
|
|
|
|
+ anchorX: 'center',
|
|
|
|
|
+ anchorY: 'top',
|
|
|
|
|
+ layer: 1
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Y 轴刻度和数字
|
|
// Y 轴刻度和数字
|
|
@@ -197,7 +223,7 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 轴名称:精确防裁切
|
|
|
|
|
|
|
+ // 轴名称
|
|
|
addObj('text', [maxD, -maxZ * 0.05, labels.horizontalDistance], {
|
|
addObj('text', [maxD, -maxZ * 0.05, labels.horizontalDistance], {
|
|
|
fontSize: 10,
|
|
fontSize: 10,
|
|
|
color: pal.dim,
|
|
color: pal.dim,
|
|
@@ -214,33 +240,61 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// ================= 二、覆盖区域和声学线 =================
|
|
// ================= 二、覆盖区域和声学线 =================
|
|
|
|
|
+ // 右侧覆盖区域
|
|
|
if (nearX !== null && farX !== null) {
|
|
if (nearX !== null && farX !== null) {
|
|
|
const leftX = Math.min(nearX, farX)
|
|
const leftX = Math.min(nearX, farX)
|
|
|
const rightX = Math.max(nearX, farX)
|
|
const rightX = Math.max(nearX, farX)
|
|
|
-
|
|
|
|
|
addObj('polygon', [pt(0, z), pt(leftX, 0), pt(rightX, 0)], {
|
|
addObj('polygon', [pt(0, z), pt(leftX, 0), pt(rightX, 0)], {
|
|
|
fillColor: pal.accent,
|
|
fillColor: pal.accent,
|
|
|
fillOpacity: 0.1,
|
|
fillOpacity: 0.1,
|
|
|
strokeColor: 'none',
|
|
strokeColor: 'none',
|
|
|
layer: 2
|
|
layer: 2
|
|
|
})
|
|
})
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'segment',
|
|
|
|
|
+ [
|
|
|
|
|
+ [leftX, 0],
|
|
|
|
|
+ [rightX, 0]
|
|
|
|
|
+ ],
|
|
|
|
|
+ {
|
|
|
|
|
+ strokeColor: pal.accent,
|
|
|
|
|
+ strokeWidth: 4,
|
|
|
|
|
+ strokeOpacity: 0.35,
|
|
|
|
|
+ layer: 2
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (nearX !== null && farX !== null && farX > nearX) {
|
|
|
|
|
|
|
+ // 左侧覆盖区域(镜像)
|
|
|
|
|
+ if (isSymmetric && leftNearX !== null && leftFarX !== null) {
|
|
|
|
|
+ const leftLeftX = Math.min(leftNearX, leftFarX)
|
|
|
|
|
+ const leftRightX = Math.max(leftNearX, leftFarX)
|
|
|
|
|
+ addObj('polygon', [pt(0, z), pt(leftLeftX, 0), pt(leftRightX, 0)], {
|
|
|
|
|
+ fillColor: pal.accent,
|
|
|
|
|
+ fillOpacity: 0.1,
|
|
|
|
|
+ strokeColor: 'none',
|
|
|
|
|
+ layer: 2
|
|
|
|
|
+ })
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
- [nearX, 0],
|
|
|
|
|
- [farX, 0]
|
|
|
|
|
|
|
+ [leftLeftX, 0],
|
|
|
|
|
+ [leftRightX, 0]
|
|
|
],
|
|
],
|
|
|
- { strokeColor: pal.accent, strokeWidth: 4, strokeOpacity: 0.35, layer: 2 }
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ strokeColor: pal.accent,
|
|
|
|
|
+ strokeWidth: 4,
|
|
|
|
|
+ strokeOpacity: 0.35,
|
|
|
|
|
+ layer: 2
|
|
|
|
|
+ }
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 辅助函数:计算超出屏幕时的射线端点
|
|
|
const boundaryPoint = (boundaryAngle: number): [number, number] | null => {
|
|
const boundaryPoint = (boundaryAngle: number): [number, number] | null => {
|
|
|
const dx = Math.cos(boundaryAngle)
|
|
const dx = Math.cos(boundaryAngle)
|
|
|
const dy = -Math.sin(boundaryAngle)
|
|
const dy = -Math.sin(boundaryAngle)
|
|
|
- const minX = -maxD * 0.1
|
|
|
|
|
|
|
+ const minX = isSymmetric ? -maxD : -maxD * 0.1 // 对称时左侧边界放宽
|
|
|
let distance = Number.POSITIVE_INFINITY
|
|
let distance = Number.POSITIVE_INFINITY
|
|
|
|
|
|
|
|
if (dx > 0.01) distance = Math.min(distance, maxD / dx)
|
|
if (dx > 0.01) distance = Math.min(distance, maxD / dx)
|
|
@@ -265,9 +319,17 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 右侧边界
|
|
|
drawBoundary(farX, lowerAngle)
|
|
drawBoundary(farX, lowerAngle)
|
|
|
drawBoundary(nearX, upperAngle)
|
|
drawBoundary(nearX, upperAngle)
|
|
|
|
|
|
|
|
|
|
+ // 左侧边界(镜像角度)
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ drawBoundary(leftFarX, Math.PI - lowerAngle)
|
|
|
|
|
+ drawBoundary(leftNearX, Math.PI - upperAngle)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 轴心线 D3
|
|
|
const d3Clamped = Math.min(maxD, d3)
|
|
const d3Clamped = Math.min(maxD, d3)
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -275,10 +337,30 @@ export function drawDiagram(
|
|
|
[0, z],
|
|
[0, z],
|
|
|
[d3Clamped, 0]
|
|
[d3Clamped, 0]
|
|
|
],
|
|
],
|
|
|
- { strokeColor: pal.accent, strokeWidth: 1.5, dash: 2, layer: 3 }
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ strokeColor: pal.accent,
|
|
|
|
|
+ strokeWidth: 1.5,
|
|
|
|
|
+ dash: 2,
|
|
|
|
|
+ layer: 3
|
|
|
|
|
+ }
|
|
|
)
|
|
)
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'segment',
|
|
|
|
|
+ [
|
|
|
|
|
+ [0, z],
|
|
|
|
|
+ [-d3Clamped, 0]
|
|
|
|
|
+ ],
|
|
|
|
|
+ {
|
|
|
|
|
+ strokeColor: pal.accent,
|
|
|
|
|
+ strokeWidth: 1.5,
|
|
|
|
|
+ dash: 2,
|
|
|
|
|
+ layer: 3
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // ================= 三、点与标签(防重叠、防溢出、强制拆行) =================
|
|
|
|
|
|
|
+ // ================= 三、点与标签 =================
|
|
|
addObj('point', [0, z], {
|
|
addObj('point', [0, z], {
|
|
|
face: '[]',
|
|
face: '[]',
|
|
|
size: 6,
|
|
size: 6,
|
|
@@ -321,26 +403,20 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const labelWidth = maxD * 0.15
|
|
const labelWidth = maxD * 0.15
|
|
|
-
|
|
|
|
|
- if (lastTier === -1) {
|
|
|
|
|
- currentTier = 0
|
|
|
|
|
- } else if (x - lastX < labelWidth) {
|
|
|
|
|
|
|
+ if (lastTier === -1) currentTier = 0
|
|
|
|
|
+ else if (x - lastX < labelWidth) {
|
|
|
currentTier = lastTier + 1
|
|
currentTier = lastTier + 1
|
|
|
if (currentTier > 2) currentTier = 0
|
|
if (currentTier > 2) currentTier = 0
|
|
|
- } else {
|
|
|
|
|
- currentTier = 0
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else currentTier = 0
|
|
|
|
|
|
|
|
lastX = x
|
|
lastX = x
|
|
|
lastTier = currentTier
|
|
lastTier = currentTier
|
|
|
|
|
|
|
|
const textY = textBaseY + currentTier * (maxZ * 0.08)
|
|
const textY = textBaseY + currentTier * (maxZ * 0.08)
|
|
|
-
|
|
|
|
|
- // 靠右边界时,文字自动向左对齐防止切出屏幕
|
|
|
|
|
const isNearRightEdge = x > maxD * 0.85
|
|
const isNearRightEdge = x > maxD * 0.85
|
|
|
const anchorX = isNearRightEdge ? 'right' : 'center'
|
|
const anchorX = isNearRightEdge ? 'right' : 'center'
|
|
|
|
|
|
|
|
- // 强制拆成两个文本对象画,避免 \n 在某些环境下失效变成一行超长文本
|
|
|
|
|
|
|
+ // 右侧点标签
|
|
|
addObj('text', [x, textY, `${ptDef.lbl} = ${x.toFixed(1)}m`], {
|
|
addObj('text', [x, textY, `${ptDef.lbl} = ${x.toFixed(1)}m`], {
|
|
|
fontSize: 10,
|
|
fontSize: 10,
|
|
|
color: ptDef.c,
|
|
color: ptDef.c,
|
|
@@ -355,11 +431,36 @@ export function drawDiagram(
|
|
|
anchorY: 'top',
|
|
anchorY: 'top',
|
|
|
layer: 4
|
|
layer: 4
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // 左侧点标签(开启对称时)
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj('point', [-x, 0], {
|
|
|
|
|
+ size: 4,
|
|
|
|
|
+ fillColor: ptDef.c,
|
|
|
|
|
+ strokeColor: pal.bg,
|
|
|
|
|
+ strokeWidth: 1,
|
|
|
|
|
+ layer: 4
|
|
|
|
|
+ })
|
|
|
|
|
+ addObj('text', [-x, textY, `${ptDef.lbl} = ${x.toFixed(1)}m`], {
|
|
|
|
|
+ fontSize: 10,
|
|
|
|
|
+ color: ptDef.c,
|
|
|
|
|
+ anchorX: 'center',
|
|
|
|
|
+ anchorY: 'bottom',
|
|
|
|
|
+ layer: 4
|
|
|
|
|
+ })
|
|
|
|
|
+ addObj('text', [-x, textY + maxZ * 0.1, `${spl.toFixed(1)} dB`], {
|
|
|
|
|
+ fontSize: 10,
|
|
|
|
|
+ color: ptDef.c,
|
|
|
|
|
+ anchorX: 'center',
|
|
|
|
|
+ anchorY: 'top',
|
|
|
|
|
+ layer: 4
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// ================= 四、弧线与角度 =================
|
|
// ================= 四、弧线与角度 =================
|
|
|
|
|
|
|
|
- // 1. 水平向右的基准虚线,标定 A 角的参考系
|
|
|
|
|
|
|
+ // 1. 水平基准虚线
|
|
|
const baseRefLineLength = maxD * 0.18
|
|
const baseRefLineLength = maxD * 0.18
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -375,24 +476,52 @@ export function drawDiagram(
|
|
|
layer: 3
|
|
layer: 3
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'segment',
|
|
|
|
|
+ [
|
|
|
|
|
+ [0, z],
|
|
|
|
|
+ [-baseRefLineLength, z]
|
|
|
|
|
+ ],
|
|
|
|
|
+ {
|
|
|
|
|
+ strokeColor: pal.dim,
|
|
|
|
|
+ strokeWidth: 1,
|
|
|
|
|
+ dash: 2,
|
|
|
|
|
+ strokeOpacity: 0.8,
|
|
|
|
|
+ layer: 3
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 2. 覆盖角 V 的圆弧(外圈)
|
|
// 2. 覆盖角 V 的圆弧(外圈)
|
|
|
- // 上边界角度 > 0°(有向下分量)时,覆盖角扇面与前方地面有交集,绘制外圈弧线
|
|
|
|
|
if (upperAngle > 0.01) {
|
|
if (upperAngle > 0.01) {
|
|
|
- // 半径与 maxZ 挂钩,确保在不同拉伸比例下都足够清晰
|
|
|
|
|
const vRadius = maxZ * 0.3
|
|
const vRadius = maxZ * 0.3
|
|
|
|
|
+ // 右侧圆弧
|
|
|
addObj(
|
|
addObj(
|
|
|
'curve',
|
|
'curve',
|
|
|
[
|
|
[
|
|
|
(t: number) => Math.cos(t) * vRadius,
|
|
(t: number) => Math.cos(t) * vRadius,
|
|
|
(t: number) => z - Math.sin(t) * vRadius,
|
|
(t: number) => z - Math.sin(t) * vRadius,
|
|
|
- lowerAngle, // 起始角(独立参数)
|
|
|
|
|
- upperAngle // 终止角(独立参数)
|
|
|
|
|
|
|
+ lowerAngle,
|
|
|
|
|
+ upperAngle
|
|
|
],
|
|
],
|
|
|
- { strokeColor: '#eab308', strokeWidth: 2.5, layer: 4 } // 加粗让它更显眼
|
|
|
|
|
|
|
+ { strokeColor: '#eab308', strokeWidth: 2.5, layer: 4 }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- // 覆盖角标签放在右上角
|
|
|
|
|
|
|
+ // 左侧镜像圆弧
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'curve',
|
|
|
|
|
+ [
|
|
|
|
|
+ (t: number) => Math.cos(t) * vRadius,
|
|
|
|
|
+ (t: number) => z - Math.sin(t) * vRadius,
|
|
|
|
|
+ Math.PI - upperAngle,
|
|
|
|
|
+ Math.PI - lowerAngle
|
|
|
|
|
+ ],
|
|
|
|
|
+ { strokeColor: '#eab308', strokeWidth: 2.5, layer: 4 }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
addObj('text', [maxD, maxZ, labels.coverageAngle], {
|
|
addObj('text', [maxD, maxZ, labels.coverageAngle], {
|
|
|
fontSize: 11,
|
|
fontSize: 11,
|
|
|
color: '#ca8a04',
|
|
color: '#ca8a04',
|
|
@@ -404,19 +533,29 @@ export function drawDiagram(
|
|
|
|
|
|
|
|
// 3. 安装倾斜角 A 的圆弧(内圈)
|
|
// 3. 安装倾斜角 A 的圆弧(内圈)
|
|
|
if (angle > 0.01) {
|
|
if (angle > 0.01) {
|
|
|
- const aRadius = maxZ * 0.16 // 内圈半径
|
|
|
|
|
|
|
+ const aRadius = maxZ * 0.16
|
|
|
|
|
+ // 右侧圆弧
|
|
|
addObj(
|
|
addObj(
|
|
|
'curve',
|
|
'curve',
|
|
|
- [
|
|
|
|
|
- (t: number) => Math.cos(t) * aRadius,
|
|
|
|
|
- (t: number) => z - Math.sin(t) * aRadius,
|
|
|
|
|
- 0, // 起始角(独立参数)
|
|
|
|
|
- aRad // 终止角(独立参数)
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ [(t: number) => Math.cos(t) * aRadius, (t: number) => z - Math.sin(t) * aRadius, 0, aRad],
|
|
|
{ strokeColor: pal.text, strokeWidth: 1.5, strokeOpacity: 0.9, layer: 4 }
|
|
{ strokeColor: pal.text, strokeWidth: 1.5, strokeOpacity: 0.9, layer: 4 }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- // A 标签放在内圈
|
|
|
|
|
|
|
+ // 左侧镜像圆弧
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'curve',
|
|
|
|
|
+ [
|
|
|
|
|
+ (t: number) => Math.cos(t) * aRadius,
|
|
|
|
|
+ (t: number) => z - Math.sin(t) * aRadius,
|
|
|
|
|
+ Math.PI - aRad,
|
|
|
|
|
+ Math.PI
|
|
|
|
|
+ ],
|
|
|
|
|
+ { strokeColor: pal.text, strokeWidth: 1.5, strokeOpacity: 0.9, layer: 4 }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 右侧标签
|
|
|
const midA = aRad / 2
|
|
const midA = aRad / 2
|
|
|
const aLblR = aRadius + maxZ * 0.04
|
|
const aLblR = aRadius + maxZ * 0.04
|
|
|
addObj(
|
|
addObj(
|
|
@@ -430,6 +569,22 @@ export function drawDiagram(
|
|
|
layer: 10
|
|
layer: 10
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+ // 左侧标签
|
|
|
|
|
+ if (isSymmetric) {
|
|
|
|
|
+ const midALeft = Math.PI - aRad / 2
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'text',
|
|
|
|
|
+ [Math.cos(midALeft) * aLblR, z - Math.sin(midALeft) * aLblR, `A = ${angle.toFixed(1)}°`],
|
|
|
|
|
+ {
|
|
|
|
|
+ fontSize: 11,
|
|
|
|
|
+ color: pal.text,
|
|
|
|
|
+ anchorX: 'right',
|
|
|
|
|
+ anchorY: 'bottom',
|
|
|
|
|
+ layer: 10
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} finally {
|
|
} finally {
|
|
|
board.unsuspendUpdate()
|
|
board.unsuspendUpdate()
|