|
@@ -48,13 +48,21 @@ 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; isSymmetric?: boolean },
|
|
|
|
|
|
|
+ p: SpeakerParams & {
|
|
|
|
|
+ maxD?: number
|
|
|
|
|
+ maxZ?: number
|
|
|
|
|
+ isSymmetric?: boolean
|
|
|
|
|
+ yAxisPosition?: 'left' | 'center'
|
|
|
|
|
+ },
|
|
|
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 isCenter = p.isSymmetric === true || p.yAxisPosition === 'center'
|
|
|
|
|
+ const showLeftSide = p.isSymmetric === true
|
|
|
|
|
+
|
|
|
const cov = dir === 'H' ? hCov : vCov
|
|
const cov = dir === 'H' ? hCov : vCov
|
|
|
const t6 = cov / 2
|
|
const t6 = cov / 2
|
|
|
|
|
|
|
@@ -71,21 +79,20 @@ export function drawDiagram(
|
|
|
const upperAngle = aRad + t6Rad
|
|
const upperAngle = aRad + t6Rad
|
|
|
const lowerAngle = aRad - t6Rad
|
|
const lowerAngle = aRad - t6Rad
|
|
|
|
|
|
|
|
- // 右侧边界与地面的交点
|
|
|
|
|
|
|
+ // 允许角度在 0~180° 之间计算交点(包含负数),并限制在屏幕宽度
|
|
|
let nearX: number | null = null
|
|
let nearX: number | null = null
|
|
|
- if (upperAngle > 0.01 && upperAngle < Math.PI / 2 - 0.01) {
|
|
|
|
|
- nearX = Math.min(maxD, Math.max(0, z / Math.tan(upperAngle)))
|
|
|
|
|
|
|
+ if (upperAngle > 0.01 && upperAngle < Math.PI - 0.01) {
|
|
|
|
|
+ nearX = Math.max(-maxD, Math.min(maxD, z / Math.tan(upperAngle)))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let farX: number | null = null
|
|
let farX: number | null = null
|
|
|
- if (lowerAngle > 0.01 && lowerAngle < Math.PI / 2 - 0.01) {
|
|
|
|
|
- farX = Math.min(maxD, z / Math.tan(lowerAngle))
|
|
|
|
|
|
|
+ if (lowerAngle > 0.01 && lowerAngle < Math.PI - 0.01) {
|
|
|
|
|
+ farX = Math.max(-maxD, Math.min(maxD, z / Math.tan(lowerAngle)))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 左侧边界与地面的交点(镜像对称)
|
|
|
|
|
let leftNearX: number | null = null
|
|
let leftNearX: number | null = null
|
|
|
let leftFarX: number | null = null
|
|
let leftFarX: number | null = null
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
leftNearX = nearX !== null ? -nearX : null
|
|
leftNearX = nearX !== null ? -nearX : null
|
|
|
leftFarX = farX !== null ? -farX : null
|
|
leftFarX = farX !== null ? -farX : null
|
|
|
}
|
|
}
|
|
@@ -113,10 +120,9 @@ export function drawDiagram(
|
|
|
const pt = (x: number, y: number) => addObj('point', [x, y], { visible: false, fixed: true })
|
|
const pt = (x: number, y: number) => addObj('point', [x, y], { visible: false, fixed: true })
|
|
|
|
|
|
|
|
// ================= 一、网格和坐标轴 =================
|
|
// ================= 一、网格和坐标轴 =================
|
|
|
- const gD = nice(maxD / 6)
|
|
|
|
|
- const gZ = nice(maxZ / 5)
|
|
|
|
|
|
|
+ const gD = nice(maxD / 8)
|
|
|
|
|
+ const gZ = nice(maxZ / 6)
|
|
|
|
|
|
|
|
- // 垂向网格线
|
|
|
|
|
for (let d = gD; d < maxD; d += gD) {
|
|
for (let d = gD; d < maxD; d += gD) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -126,7 +132,7 @@ 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) {
|
|
|
|
|
|
|
+ if (isCenter) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
@@ -138,19 +144,17 @@ export function drawDiagram(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 水平网格线
|
|
|
|
|
for (let h = gZ; h < maxZ; h += gZ) {
|
|
for (let h = gZ; h < maxZ; h += gZ) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
- [isSymmetric ? -maxD : 0, h],
|
|
|
|
|
|
|
+ [isCenter ? -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',
|
|
|
[
|
|
[
|
|
@@ -162,13 +166,12 @@ export function drawDiagram(
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
- [isSymmetric ? -maxD : 0, 0],
|
|
|
|
|
|
|
+ [isCenter ? -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 }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- // X 轴刻度和数字
|
|
|
|
|
for (let d = gD; d < maxD; d += gD) {
|
|
for (let d = gD; d < maxD; d += gD) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -185,7 +188,7 @@ export function drawDiagram(
|
|
|
anchorY: 'top',
|
|
anchorY: 'top',
|
|
|
layer: 1
|
|
layer: 1
|
|
|
})
|
|
})
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (isCenter) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
@@ -204,7 +207,6 @@ export function drawDiagram(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Y 轴刻度和数字
|
|
|
|
|
for (let h = gZ; h < maxZ; h += gZ) {
|
|
for (let h = gZ; h < maxZ; h += gZ) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -223,7 +225,6 @@ 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,
|
|
@@ -240,61 +241,31 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// ================= 二、覆盖区域和声学线 =================
|
|
// ================= 二、覆盖区域和声学线 =================
|
|
|
- // 右侧覆盖区域
|
|
|
|
|
|
|
+ // 【核心修复】:以 Y 轴为界,左右两侧单独绘制多边形,防止跨中轴合并变成巨型色块
|
|
|
if (nearX !== null && farX !== null) {
|
|
if (nearX !== null && farX !== null) {
|
|
|
- const leftX = Math.min(nearX, farX)
|
|
|
|
|
- const rightX = Math.max(nearX, farX)
|
|
|
|
|
- addObj('polygon', [pt(0, z), pt(leftX, 0), pt(rightX, 0)], {
|
|
|
|
|
- fillColor: pal.accent,
|
|
|
|
|
- fillOpacity: 0.1,
|
|
|
|
|
- strokeColor: 'none',
|
|
|
|
|
- layer: 2
|
|
|
|
|
- })
|
|
|
|
|
- addObj(
|
|
|
|
|
- 'segment',
|
|
|
|
|
- [
|
|
|
|
|
- [leftX, 0],
|
|
|
|
|
- [rightX, 0]
|
|
|
|
|
- ],
|
|
|
|
|
- {
|
|
|
|
|
- strokeColor: pal.accent,
|
|
|
|
|
- strokeWidth: 4,
|
|
|
|
|
- strokeOpacity: 0.35,
|
|
|
|
|
|
|
+ const x1 = Math.min(nearX, farX)
|
|
|
|
|
+ const x2 = Math.max(nearX, farX)
|
|
|
|
|
+ if (x2 > x1 + 0.01) {
|
|
|
|
|
+ addObj('polygon', [pt(0, z), pt(x1, 0), pt(x2, 0)], {
|
|
|
|
|
+ fillColor: pal.accent,
|
|
|
|
|
+ fillOpacity: 0.1,
|
|
|
|
|
+ strokeColor: 'none',
|
|
|
layer: 2
|
|
layer: 2
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 左侧覆盖区域(镜像)
|
|
|
|
|
- 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(
|
|
|
|
|
- 'segment',
|
|
|
|
|
- [
|
|
|
|
|
- [leftLeftX, 0],
|
|
|
|
|
- [leftRightX, 0]
|
|
|
|
|
- ],
|
|
|
|
|
- {
|
|
|
|
|
- strokeColor: pal.accent,
|
|
|
|
|
- strokeWidth: 4,
|
|
|
|
|
- strokeOpacity: 0.35,
|
|
|
|
|
- layer: 2
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ addObj(
|
|
|
|
|
+ 'segment',
|
|
|
|
|
+ [
|
|
|
|
|
+ [x1, 0],
|
|
|
|
|
+ [x2, 0]
|
|
|
|
|
+ ],
|
|
|
|
|
+ { 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 = isSymmetric ? -maxD : -maxD * 0.1 // 对称时左侧边界放宽
|
|
|
|
|
|
|
+ const minX = isCenter ? -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)
|
|
@@ -319,17 +290,14 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 右侧边界
|
|
|
|
|
drawBoundary(farX, lowerAngle)
|
|
drawBoundary(farX, lowerAngle)
|
|
|
drawBoundary(nearX, upperAngle)
|
|
drawBoundary(nearX, upperAngle)
|
|
|
|
|
|
|
|
- // 左侧边界(镜像角度)
|
|
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
drawBoundary(leftFarX, Math.PI - lowerAngle)
|
|
drawBoundary(leftFarX, Math.PI - lowerAngle)
|
|
|
drawBoundary(leftNearX, Math.PI - upperAngle)
|
|
drawBoundary(leftNearX, Math.PI - upperAngle)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 轴心线 D3
|
|
|
|
|
const d3Clamped = Math.min(maxD, d3)
|
|
const d3Clamped = Math.min(maxD, d3)
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -337,26 +305,16 @@ 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) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
[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 }
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -416,7 +374,6 @@ export function drawDiagram(
|
|
|
const isNearRightEdge = x > maxD * 0.85
|
|
const isNearRightEdge = x > maxD * 0.85
|
|
|
const anchorX = isNearRightEdge ? 'right' : 'center'
|
|
const anchorX = isNearRightEdge ? 'right' : 'center'
|
|
|
|
|
|
|
|
- // 右侧点标签
|
|
|
|
|
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,
|
|
@@ -432,8 +389,7 @@ export function drawDiagram(
|
|
|
layer: 4
|
|
layer: 4
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- // 左侧点标签(开启对称时)
|
|
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
addObj('point', [-x, 0], {
|
|
addObj('point', [-x, 0], {
|
|
|
size: 4,
|
|
size: 4,
|
|
|
fillColor: ptDef.c,
|
|
fillColor: ptDef.c,
|
|
@@ -441,17 +397,18 @@ export function drawDiagram(
|
|
|
strokeWidth: 1,
|
|
strokeWidth: 1,
|
|
|
layer: 4
|
|
layer: 4
|
|
|
})
|
|
})
|
|
|
|
|
+ const anchorXLeft = -x < -maxD * 0.85 ? 'left' : 'center'
|
|
|
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,
|
|
|
- anchorX: 'center',
|
|
|
|
|
|
|
+ anchorX: anchorXLeft,
|
|
|
anchorY: 'bottom',
|
|
anchorY: 'bottom',
|
|
|
layer: 4
|
|
layer: 4
|
|
|
})
|
|
})
|
|
|
addObj('text', [-x, textY + maxZ * 0.1, `${spl.toFixed(1)} dB`], {
|
|
addObj('text', [-x, textY + maxZ * 0.1, `${spl.toFixed(1)} dB`], {
|
|
|
fontSize: 10,
|
|
fontSize: 10,
|
|
|
color: ptDef.c,
|
|
color: ptDef.c,
|
|
|
- anchorX: 'center',
|
|
|
|
|
|
|
+ anchorX: anchorXLeft,
|
|
|
anchorY: 'top',
|
|
anchorY: 'top',
|
|
|
layer: 4
|
|
layer: 4
|
|
|
})
|
|
})
|
|
@@ -459,8 +416,6 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// ================= 四、弧线与角度 =================
|
|
// ================= 四、弧线与角度 =================
|
|
|
-
|
|
|
|
|
- // 1. 水平基准虚线
|
|
|
|
|
const baseRefLineLength = maxD * 0.18
|
|
const baseRefLineLength = maxD * 0.18
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
@@ -468,35 +423,22 @@ export function drawDiagram(
|
|
|
[0, z],
|
|
[0, z],
|
|
|
[baseRefLineLength, z]
|
|
[baseRefLineLength, z]
|
|
|
],
|
|
],
|
|
|
- {
|
|
|
|
|
- strokeColor: pal.dim,
|
|
|
|
|
- strokeWidth: 1,
|
|
|
|
|
- dash: 2,
|
|
|
|
|
- strokeOpacity: 0.8,
|
|
|
|
|
- layer: 3
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ { strokeColor: pal.dim, strokeWidth: 1, dash: 2, strokeOpacity: 0.8, layer: 3 }
|
|
|
)
|
|
)
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'segment',
|
|
'segment',
|
|
|
[
|
|
[
|
|
|
[0, z],
|
|
[0, z],
|
|
|
[-baseRefLineLength, z]
|
|
[-baseRefLineLength, z]
|
|
|
],
|
|
],
|
|
|
- {
|
|
|
|
|
- strokeColor: pal.dim,
|
|
|
|
|
- strokeWidth: 1,
|
|
|
|
|
- dash: 2,
|
|
|
|
|
- strokeOpacity: 0.8,
|
|
|
|
|
- layer: 3
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ { strokeColor: pal.dim, strokeWidth: 1, dash: 2, strokeOpacity: 0.8, layer: 3 }
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 2. 覆盖角 V 的圆弧(外圈)
|
|
|
|
|
|
|
+ // 覆盖角 V 的圆弧(外圈)
|
|
|
if (upperAngle > 0.01) {
|
|
if (upperAngle > 0.01) {
|
|
|
const vRadius = Math.min(maxZ * 0.15, z * 0.5)
|
|
const vRadius = Math.min(maxZ * 0.15, z * 0.5)
|
|
|
- // 右侧圆弧
|
|
|
|
|
addObj(
|
|
addObj(
|
|
|
'curve',
|
|
'curve',
|
|
|
[
|
|
[
|
|
@@ -508,8 +450,7 @@ export function drawDiagram(
|
|
|
{ strokeColor: '#eab308', strokeWidth: 2, layer: 4 }
|
|
{ strokeColor: '#eab308', strokeWidth: 2, layer: 4 }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- // 左侧镜像圆弧
|
|
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide && Math.abs(angle - 90) > 0.01) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'curve',
|
|
'curve',
|
|
|
[
|
|
[
|
|
@@ -531,18 +472,16 @@ export function drawDiagram(
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 3. 安装倾斜角 A 的圆弧(内圈)
|
|
|
|
|
|
|
+ // 安装倾斜角 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 }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- // 左侧镜像圆弧
|
|
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
addObj(
|
|
addObj(
|
|
|
'curve',
|
|
'curve',
|
|
|
[
|
|
[
|
|
@@ -555,34 +494,20 @@ export function drawDiagram(
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 右侧标签
|
|
|
|
|
const midA = aRad / 2
|
|
const midA = aRad / 2
|
|
|
const aLblR = aRadius + maxZ * 0.04
|
|
const aLblR = aRadius + maxZ * 0.04
|
|
|
addObj(
|
|
addObj(
|
|
|
'text',
|
|
'text',
|
|
|
[Math.cos(midA) * aLblR, z - Math.sin(midA) * aLblR, `A = ${angle.toFixed(1)}°`],
|
|
[Math.cos(midA) * aLblR, z - Math.sin(midA) * aLblR, `A = ${angle.toFixed(1)}°`],
|
|
|
- {
|
|
|
|
|
- fontSize: 11,
|
|
|
|
|
- color: pal.text,
|
|
|
|
|
- anchorX: 'left',
|
|
|
|
|
- anchorY: 'bottom',
|
|
|
|
|
- layer: 10
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ { fontSize: 11, color: pal.text, anchorX: 'left', anchorY: 'bottom', layer: 10 }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- // 左侧标签
|
|
|
|
|
- if (isSymmetric) {
|
|
|
|
|
|
|
+ if (showLeftSide) {
|
|
|
const midALeft = Math.PI - aRad / 2
|
|
const midALeft = Math.PI - aRad / 2
|
|
|
addObj(
|
|
addObj(
|
|
|
'text',
|
|
'text',
|
|
|
[Math.cos(midALeft) * aLblR, z - Math.sin(midALeft) * aLblR, `A = ${angle.toFixed(1)}°`],
|
|
[Math.cos(midALeft) * aLblR, z - Math.sin(midALeft) * aLblR, `A = ${angle.toFixed(1)}°`],
|
|
|
- {
|
|
|
|
|
- fontSize: 11,
|
|
|
|
|
- color: pal.text,
|
|
|
|
|
- anchorX: 'right',
|
|
|
|
|
- anchorY: 'bottom',
|
|
|
|
|
- layer: 10
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ { fontSize: 11, color: pal.text, anchorX: 'right', anchorY: 'bottom', layer: 10 }
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|