@edubeam/plot 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,135 @@
1
+ /**
2
+ * The plain-data model the drawing is made from. Everything is SI (m, N, N·m, N/m, K, rad) in the
3
+ * solver's axes: x to the right, z down, rotations about y positive counter-clockwise on screen.
4
+ * It is JSON-serialisable, so a page can solve at build time and ship only this.
5
+ */
6
+ import type { Piecewise } from './polynomial.js';
7
+ export interface Fixity {
8
+ readonly dx: boolean;
9
+ readonly dz: boolean;
10
+ readonly ry: boolean;
11
+ }
12
+ export interface PlotNode {
13
+ readonly id: string;
14
+ readonly x: number;
15
+ readonly z: number;
16
+ readonly fixity: Fixity;
17
+ /** Rotation of the node's own axes (a rotated support), rad from x toward z: clockwise on screen. */
18
+ readonly angle: number;
19
+ }
20
+ export interface PlotMember {
21
+ readonly id: string;
22
+ readonly start: string;
23
+ readonly end: string;
24
+ /** Moment releases at the start and end node. */
25
+ readonly hinges: readonly [boolean, boolean];
26
+ }
27
+ /** A force per unit length, N/m, in global or member-local components. */
28
+ export interface LineIntensity {
29
+ readonly fx: number;
30
+ readonly fz: number;
31
+ }
32
+ export type PlotLoad =
33
+ /** A force at a node, global components, N. */
34
+ {
35
+ readonly kind: 'nodalForce';
36
+ readonly node: string;
37
+ readonly fx: number;
38
+ readonly fz: number;
39
+ }
40
+ /** A moment at a node, N·m, positive counter-clockwise on screen. */
41
+ | {
42
+ readonly kind: 'nodalMoment';
43
+ readonly node: string;
44
+ readonly my: number;
45
+ }
46
+ /** Linearly varying load over the whole member; a uniform load has start equal to end. */
47
+ | {
48
+ readonly kind: 'distributed';
49
+ readonly member: string;
50
+ readonly start: LineIntensity;
51
+ readonly end: LineIntensity;
52
+ /** Components along the member's local x and z rather than the global axes. */
53
+ readonly local: boolean;
54
+ }
55
+ /** A force on a member `at` metres from its start node. */
56
+ | {
57
+ readonly kind: 'pointForce';
58
+ readonly member: string;
59
+ readonly at: number;
60
+ readonly fx: number;
61
+ readonly fz: number;
62
+ readonly local: boolean;
63
+ } | {
64
+ readonly kind: 'pointMoment';
65
+ readonly member: string;
66
+ readonly at: number;
67
+ readonly my: number;
68
+ }
69
+ /** Temperature change, K: of the centroid, and bottom minus top fibres (ΔTb − ΔTt). */
70
+ | {
71
+ readonly kind: 'temperature';
72
+ readonly member: string;
73
+ readonly uniform: number;
74
+ readonly gradient: number;
75
+ }
76
+ /** Imposed displacement of a support, in the node's axes: m and rad. */
77
+ | {
78
+ readonly kind: 'prescribed';
79
+ readonly node: string;
80
+ readonly dx?: number;
81
+ readonly dz?: number;
82
+ readonly ry?: number;
83
+ };
84
+ export type PlotLoadKind = PlotLoad['kind'];
85
+ export type ReactionDof = 'dx' | 'dz' | 'ry';
86
+ export interface PlotReaction {
87
+ readonly node: string;
88
+ readonly dof: ReactionDof;
89
+ /** Force on the structure along the node's axis, N (or N·m about y for `ry`). */
90
+ readonly value: number;
91
+ }
92
+ /** Member results along local x in metres: forces in N and N·m, displacements in m. */
93
+ export interface MemberResults {
94
+ /** Normal force, tension positive. */
95
+ readonly N: Piecewise;
96
+ /** Shear force. */
97
+ readonly V: Piecewise;
98
+ /** Bending moment, sagging (tension on the side of local +z) positive. */
99
+ readonly M: Piecewise;
100
+ /** Displacement along local x. */
101
+ readonly u: Piecewise;
102
+ /** Displacement along local z (down for a member drawn left to right). */
103
+ readonly w: Piecewise;
104
+ }
105
+ export interface PlotResults {
106
+ readonly members: Readonly<Record<string, MemberResults>>;
107
+ readonly reactions: readonly PlotReaction[];
108
+ }
109
+ export interface PlotModel {
110
+ readonly nodes: readonly PlotNode[];
111
+ readonly members: readonly PlotMember[];
112
+ readonly loads: readonly PlotLoad[];
113
+ /** Absent until the structure is solved: the drawing then shows the model alone. */
114
+ readonly results?: PlotResults;
115
+ }
116
+ export type InternalForce = 'N' | 'V' | 'M';
117
+ /** A member's axis on the model: where it starts, its unit tangent and its local z, and its length. */
118
+ export interface MemberFrame {
119
+ readonly x: number;
120
+ readonly z: number;
121
+ /** Unit tangent, start to end. */
122
+ readonly tx: number;
123
+ readonly tz: number;
124
+ /** Unit local z: the tangent turned 90° clockwise on screen - the side of the dashed fibres. */
125
+ readonly nx: number;
126
+ readonly nz: number;
127
+ readonly length: number;
128
+ }
129
+ export declare const nodeMap: (model: PlotModel) => ReadonlyMap<string, PlotNode>;
130
+ export declare const memberFrame: (model: PlotModel, member: PlotMember, nodes?: ReadonlyMap<string, PlotNode>) => MemberFrame;
131
+ /** The point `at` metres along the member. */
132
+ export declare const pointAlong: (frame: MemberFrame, at: number) => {
133
+ x: number;
134
+ z: number;
135
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Piecewise polynomials: the exact form of every beam result between two points where a point load
3
+ * breaks it. N, V and M are at most cubic and the deflection at most quintic, so a handful of
4
+ * coefficients per piece holds the solver's answer exactly, can be stored as plain JSON, and gives
5
+ * any value, extreme or curve without sampling the solver again.
6
+ */
7
+ /**
8
+ * One piece over [x0, x1] (metres along the member), value = Σ c[k]·sᵏ with s = (x − x0)/(x1 − x0).
9
+ * The normalised parameter keeps the fit well conditioned whatever the member's length.
10
+ */
11
+ export interface Piece {
12
+ readonly x0: number;
13
+ readonly x1: number;
14
+ readonly c: readonly number[];
15
+ }
16
+ export type Piecewise = readonly Piece[];
17
+ export type Side = 'left' | 'right';
18
+ export declare const evalPiece: (piece: Piece, x: number) => number;
19
+ /** dv/dx in value units per metre. */
20
+ export declare const evalPieceSlope: (piece: Piece, x: number) => number;
21
+ /**
22
+ * The polynomial of the given degree through `f` on (x0, x1). It samples only interior points
23
+ * (Chebyshev nodes), so a jump at either end - a point load, or the solver returning the value just
24
+ * right of one - never leaks into the piece: its end values are the one-sided limits.
25
+ */
26
+ export declare const fitPiece: (f: (x: number) => number, x0: number, x1: number, degree: number) => Piece;
27
+ /** Largest |value| over the pieces, end values and interior extremes included. */
28
+ export declare const maxAbs: (pw: Piecewise) => number;
29
+ /**
30
+ * Drops coefficients below `tolerance`: the round-off a solved structure leaves in a value that is
31
+ * zero (a truss bar's moment) or a term that is absent (the cubic term of a uniformly loaded span).
32
+ */
33
+ export declare const cleanPiecewise: (pw: Piecewise, tolerance: number) => Piecewise;
34
+ /** Polynomial degree of a cleaned piece, or null when it is zero throughout. */
35
+ export declare const pieceDegree: (piece: Piece) => number | null;
36
+ export declare const isZero: (pw: Piecewise) => boolean;
37
+ /**
38
+ * Where the slope is zero inside the piece, in metres. Bisection on a fine grid of the derivative
39
+ * finds every root of a polynomial up to the quintic deflection, to machine precision.
40
+ */
41
+ export declare const pieceExtrema: (piece: Piece) => number[];
42
+ /**
43
+ * The value at x. Where two pieces meet there are two values - either side of a point load - and
44
+ * `side` picks one; past the ends the nearest end value is returned.
45
+ */
46
+ export declare const valueAt: (pw: Piecewise, x: number, side?: Side) => number;
47
+ export declare const slopeAt: (pw: Piecewise, x: number, side?: Side) => number;
48
+ /** The positions where pieces meet, without the two ends. */
49
+ export declare const innerBreaks: (pw: Piecewise) => number[];
50
+ /** A cubic Bézier in (position, value): start, two controls, end. */
51
+ export type CubicSegment = readonly [
52
+ readonly [number, number],
53
+ readonly [number, number],
54
+ readonly [number, number],
55
+ readonly [number, number]
56
+ ];
57
+ /**
58
+ * The piece as cubic Béziers in (x, value). A piece of degree three or less is one segment and is
59
+ * exact - a cubic Hermite through the end values and slopes is the cubic itself. A higher degree
60
+ * (the deflection under a distributed load) is split into `segments` Hermite cubics.
61
+ */
62
+ export declare const pieceToBeziers: (piece: Piece, segments?: number) => CubicSegment[];
63
+ /** Where the piecewise function is largest and smallest, with the side the value is taken from. */
64
+ export interface Extreme {
65
+ readonly x: number;
66
+ readonly value: number;
67
+ readonly side: Side;
68
+ }
69
+ export declare const extremes: (pw: Piecewise) => {
70
+ max: Extreme;
71
+ min: Extreme;
72
+ } | null;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Reading values off a plot: the member point under the pointer, and the results there - both
3
+ * values where a point load or a support makes a step.
4
+ */
5
+ import { type MemberResults, type PlotModel } from './model.js';
6
+ import { type Tone, type Transform } from './scene.js';
7
+ import { type Units } from './units.js';
8
+ /** Either side of a point; the two are equal where the result is continuous. */
9
+ export interface SidedValue {
10
+ readonly left: number;
11
+ readonly right: number;
12
+ }
13
+ export type ReadoutQuantity = 'N' | 'V' | 'M' | 'w';
14
+ export interface Readout {
15
+ readonly member: string;
16
+ /** Metres along the member from its start node. */
17
+ readonly x: number;
18
+ /** The member point on screen, px. */
19
+ readonly px: number;
20
+ readonly py: number;
21
+ readonly values: Readonly<Record<ReadoutQuantity, SidedValue>>;
22
+ /** Displacement along the member's local x there, m. */
23
+ readonly u: number;
24
+ }
25
+ /** The results at x, snapping to a break within `snap` metres so a step shows both its values. */
26
+ export declare const readMember: (results: MemberResults, x: number, snap?: number) => {
27
+ x: number;
28
+ u: number;
29
+ values: Record<ReadoutQuantity, SidedValue>;
30
+ };
31
+ /** The member nearest the screen point (px, py), within `reach` px, and its results there. */
32
+ export declare const readoutAt: (model: PlotModel, t: Transform, px: number, py: number, reach: number) => Readout | null;
33
+ /** Where a read value sits on the drawing: on its diagram's outline, or on the deformed shape. */
34
+ export interface ReadoutMark {
35
+ readonly tone: Tone;
36
+ /** The member point, px. */
37
+ readonly from: readonly [number, number];
38
+ /** The ordinate's tip (or the displaced point), px. */
39
+ readonly to: readonly [number, number];
40
+ }
41
+ /**
42
+ * The points on the drawn results that a readout's values belong to: the tip of each shown
43
+ * diagram's ordinate (both tips across a step), and the point on the deformed shape. `k` is px
44
+ * per SI unit, `side` the side each diagram is drawn on (see `diagramScales`, `diagramSide`).
45
+ */
46
+ export declare const readoutMarks: (model: PlotModel, t: Transform, r: Readout, shown: readonly ReadoutQuantity[], k: Readonly<Record<ReadoutQuantity, number>>, side: Readonly<Record<"N" | "V" | "M", 1 | -1>>) => ReadoutMark[];
47
+ /** "M = 54 kNm", or "V = 13.3 → −6.7 kN" across a step. */
48
+ export declare const formatReadout: (r: Readout, q: ReadoutQuantity, units: Units, format?: Intl.NumberFormat) => string;
@@ -0,0 +1,248 @@
1
+ /**
2
+ * A drawing as data. Every point is a model position (m) plus an offset in screen pixels, so
3
+ * symbols, arrows, diagram ordinates and text keep their size whatever the model's scale, and the
4
+ * fit can reserve exactly the room they need. Pure: no Vue, no DOM.
5
+ */
6
+ /** A model point (x right, z down, m) moved by (dx, dy) screen pixels. */
7
+ export interface Anchor {
8
+ readonly x: number;
9
+ readonly z: number;
10
+ readonly dx: number;
11
+ readonly dy: number;
12
+ }
13
+ export type Tone = 'ink' | 'muted' | 'brand' | 'normal' | 'shear' | 'moment' | 'deformed' | 'load' | 'reaction' | 'tension' | 'compression';
14
+ export type Segment = {
15
+ readonly op: 'M' | 'L';
16
+ readonly p: Anchor;
17
+ } | {
18
+ readonly op: 'C';
19
+ readonly c1: Anchor;
20
+ readonly c2: Anchor;
21
+ readonly p: Anchor;
22
+ }
23
+ /** A circular arc of radius r px around `center`, to p. */
24
+ | {
25
+ readonly op: 'A';
26
+ readonly r: number;
27
+ readonly large: boolean;
28
+ /** Clockwise on screen. */
29
+ readonly clockwise: boolean;
30
+ readonly center: Anchor;
31
+ readonly p: Anchor;
32
+ } | {
33
+ readonly op: 'Z';
34
+ };
35
+ /** Paint order, back to front. */
36
+ export declare const LAYERS: {
37
+ readonly diagramFill: 0;
38
+ readonly diagramHatch: 1;
39
+ readonly diagramLine: 2;
40
+ readonly deformed: 3;
41
+ readonly member: 4;
42
+ readonly hinge: 5;
43
+ readonly support: 6;
44
+ readonly load: 7;
45
+ readonly reaction: 8;
46
+ readonly label: 9;
47
+ };
48
+ export type LayerIndex = (typeof LAYERS)[keyof typeof LAYERS];
49
+ /** What every item carries: the caller's layer it belongs to, which switches it on and off. */
50
+ interface SceneBase {
51
+ readonly group: string;
52
+ }
53
+ export interface ScenePath extends SceneBase {
54
+ readonly kind: 'path';
55
+ readonly layer: LayerIndex;
56
+ readonly segments: readonly Segment[];
57
+ readonly tone: Tone;
58
+ /** Stroke width in px; 0 for none. */
59
+ readonly width: number;
60
+ readonly fill?: 'tone' | 'paper';
61
+ readonly fillOpacity?: number;
62
+ readonly opacity?: number;
63
+ readonly dash?: string;
64
+ /** Kept out of the fit: lines that stay inside something already fitted. */
65
+ readonly fitIgnore?: boolean;
66
+ readonly cap?: 'round' | 'butt';
67
+ /** A label may not cover this line (the members). */
68
+ readonly obstacle?: boolean;
69
+ /**
70
+ * Only the labels of other, always-on layers (loads, reactions) may not cover this line: a
71
+ * diagram's outline, which its own numbers sit against.
72
+ */
73
+ readonly shield?: boolean;
74
+ /** Drawn on from start to end when it appears; the number staggers members one after another. */
75
+ readonly draw?: number;
76
+ }
77
+ export type TextAlign = 'start' | 'middle' | 'end';
78
+ export type TextBaseline = 'top' | 'middle' | 'bottom';
79
+ /** Where a label sits: the point it hangs from and how it is aligned there. */
80
+ export interface TextPlacement {
81
+ readonly at: Anchor;
82
+ readonly align: TextAlign;
83
+ readonly baseline: TextBaseline;
84
+ /** A shorter wording (a value without its unit) for a tight spot. */
85
+ readonly text?: string;
86
+ /** A smaller font, px, for a tight spot. */
87
+ readonly size?: number;
88
+ /** Clockwise turn, degrees. */
89
+ readonly rotate?: number;
90
+ }
91
+ export interface SceneText extends SceneBase {
92
+ readonly kind: 'text';
93
+ readonly layer: LayerIndex;
94
+ readonly at: Anchor;
95
+ readonly text: string;
96
+ readonly tone: Tone;
97
+ readonly align: TextAlign;
98
+ readonly baseline: TextBaseline;
99
+ /** Higher wins when two labels would overlap; the other is left out. */
100
+ readonly priority: number;
101
+ /** Clockwise turn, degrees. */
102
+ readonly rotate?: number;
103
+ readonly italic?: boolean;
104
+ readonly weight?: number;
105
+ /** Font size, px; the plot's own when left out. */
106
+ readonly size?: number;
107
+ /** Written after `text`, smaller and lower: the x of A_x. */
108
+ readonly sub?: string;
109
+ /** Other places to try, in order, when the first is taken. */
110
+ readonly alternatives?: readonly TextPlacement[];
111
+ }
112
+ export interface SceneCircle extends SceneBase {
113
+ readonly kind: 'circle';
114
+ readonly layer: LayerIndex;
115
+ readonly at: Anchor;
116
+ readonly r: number;
117
+ readonly tone: Tone;
118
+ readonly width: number;
119
+ readonly fill: 'paper' | 'tone';
120
+ }
121
+ export type SceneItem = ScenePath | SceneText | SceneCircle;
122
+ export declare const anchor: (x: number, z: number, dx?: number, dy?: number) => Anchor;
123
+ export declare const shift: (a: Anchor, dx: number, dy: number) => Anchor;
124
+ /** Screen transform: px = tx + s·x + dx, py = ty + s·z + dy. */
125
+ export interface Transform {
126
+ readonly s: number;
127
+ readonly tx: number;
128
+ readonly ty: number;
129
+ }
130
+ export declare const project: (t: Transform, a: Anchor) => [number, number];
131
+ export declare const textWidth: (text: string, size: number) => number;
132
+ /** A subscript's size, as a share of its text's */
133
+ export declare const SUB_SCALE = 0.75;
134
+ /** How far a subscript drops below the baseline, as a share of its text's size */
135
+ export declare const SUB_DROP = 0.28;
136
+ /** The text's box around its anchor, before any rotation, in px. */
137
+ export declare const textBox: (text: string, size: number, align: TextAlign, baseline: TextBaseline, sub?: string) => {
138
+ x0: number;
139
+ x1: number;
140
+ y0: number;
141
+ y1: number;
142
+ };
143
+ /** Where the baseline goes for each vertical alignment, as a share of the font size. */
144
+ export declare const BASELINE_SHIFT: Record<TextBaseline, number>;
145
+ export interface Bounds {
146
+ minX: number;
147
+ maxX: number;
148
+ minY: number;
149
+ maxY: number;
150
+ }
151
+ /** The screen box of a text item at transform t, rotation included. */
152
+ export declare const textBounds: (item: SceneText, t: Transform, fontSize: number) => Bounds;
153
+ /** Everything the scene paints, at scale s with no translation. */
154
+ export declare const sceneBounds: (items: readonly SceneItem[], s: number, fontSize: number) => Bounds;
155
+ export interface FitBox {
156
+ /** Available width, px. */
157
+ readonly width: number;
158
+ /** Fixed height, px; leave out to size the height to the content. */
159
+ readonly height?: number;
160
+ /** Upper bound for an automatic height. */
161
+ readonly maxHeight?: number;
162
+ readonly padding: number;
163
+ readonly fontSize: number;
164
+ }
165
+ export interface Fit extends Transform {
166
+ readonly width: number;
167
+ readonly height: number;
168
+ }
169
+ /**
170
+ * The largest scale at which everything fits the box, centred in it. Width and height grow with
171
+ * the scale like the maximum of linear functions, so the feasible scales are an interval from zero
172
+ * and bisection finds its end.
173
+ */
174
+ export declare const fitScene: (items: readonly SceneItem[], box: FitBox) => Fit;
175
+ export interface ResolvedPath {
176
+ readonly group: string;
177
+ readonly d: string;
178
+ readonly layer: LayerIndex;
179
+ readonly tone: Tone;
180
+ readonly width: number;
181
+ readonly fill?: 'tone' | 'paper';
182
+ readonly fillOpacity?: number;
183
+ readonly opacity?: number;
184
+ readonly dash?: string;
185
+ readonly cap?: 'round' | 'butt';
186
+ readonly draw?: number;
187
+ }
188
+ export interface ResolvedText {
189
+ readonly group: string;
190
+ readonly x: number;
191
+ readonly y: number;
192
+ readonly text: string;
193
+ readonly tone: Tone;
194
+ readonly anchor: TextAlign;
195
+ readonly transform?: string;
196
+ readonly italic?: boolean;
197
+ readonly weight?: number;
198
+ readonly size?: number;
199
+ readonly sub?: string;
200
+ }
201
+ export interface ResolvedCircle {
202
+ readonly group: string;
203
+ readonly cx: number;
204
+ readonly cy: number;
205
+ readonly r: number;
206
+ readonly layer: LayerIndex;
207
+ readonly tone: Tone;
208
+ readonly width: number;
209
+ readonly fill: 'paper' | 'tone';
210
+ }
211
+ export interface ResolvedScene {
212
+ readonly paths: readonly ResolvedPath[];
213
+ readonly circles: readonly ResolvedCircle[];
214
+ readonly texts: readonly ResolvedText[];
215
+ }
216
+ export declare const pathData: (segments: readonly Segment[], t: Transform) => string;
217
+ /** Whether the segment p–q passes through the box (Liang-Barsky clipping). */
218
+ export declare const segmentHitsBox: (p: readonly [number, number], q: readonly [number, number], box: Bounds) => boolean;
219
+ export interface ResolveOptions {
220
+ readonly fontSize: number;
221
+ /** Labels must lie inside this box, px; ones that do not are left out. */
222
+ readonly viewport?: {
223
+ readonly width: number;
224
+ readonly height: number;
225
+ };
226
+ /** Labels that must be left out whatever room there is. */
227
+ readonly exclude?: ReadonlySet<SceneText>;
228
+ /**
229
+ * Groups that are never shown together (one result diagram at a time): their labels are placed
230
+ * after everything else and give way to it, but not to each other, so a hidden diagram's numbers
231
+ * never push out a load's value or the numbers of the diagram on show.
232
+ */
233
+ readonly alternativeGroups?: ReadonlySet<string>;
234
+ /**
235
+ * The groups whose `shield` lines count (the diagrams on show); all of them when left out. A
236
+ * hidden diagram does not keep a load's value off the place it would take.
237
+ */
238
+ readonly shields?: ReadonlySet<string>;
239
+ }
240
+ /**
241
+ * Which labels to draw. By priority, a label is kept unless it would overlap one already kept,
242
+ * cross a member, or leave the viewport - so the figure never shows two numbers on top of each
243
+ * other or a number struck through by the structure.
244
+ */
245
+ export declare const placeLabels: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => Map<SceneText, SceneText>;
246
+ /** Screen geometry for the scene, with the labels `placeLabels` keeps. */
247
+ export declare const resolveScene: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => ResolvedScene;
248
+ export {};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The stacked textbook figure: a straight beam with its loads, and beneath it on one x axis the
3
+ * diagrams of N, V, M and the deflection w. Pure geometry; DiagramStack.vue draws it.
4
+ */
5
+ import { type PlotLoad, type PlotModel } from './model.js';
6
+ import { type Piecewise, type Side } from './polynomial.js';
7
+ export type StackRow = 'N' | 'V' | 'M' | 'w';
8
+ export interface LineMember {
9
+ readonly id: string;
10
+ /** Distance of the member's start from the line's start, m. */
11
+ readonly offset: number;
12
+ readonly length: number;
13
+ }
14
+ export interface BeamLine {
15
+ readonly members: readonly LineMember[];
16
+ /** Model x and z of the line's start. */
17
+ readonly x0: number;
18
+ readonly z: number;
19
+ readonly length: number;
20
+ /** Nodes on the line with their distance from its start. */
21
+ readonly nodes: readonly {
22
+ readonly id: string;
23
+ readonly at: number;
24
+ }[];
25
+ }
26
+ /**
27
+ * The members as one horizontal line, left to right. The figure's x axis is the beam's, so an
28
+ * inclined or broken line, or a member drawn right to left (whose shear would read backwards), is
29
+ * refused rather than drawn wrongly.
30
+ */
31
+ export declare const beamLine: (model: PlotModel, ids?: readonly string[]) => BeamLine;
32
+ /** One result along the whole line, as a single piecewise polynomial in the line's x. */
33
+ export declare const lineDiagram: (model: PlotModel, line: BeamLine, row: StackRow) => Piecewise;
34
+ /** The model restricted to the line: its nodes and members, the loads on them and their reactions. */
35
+ export declare const lineModel: (model: PlotModel, line: BeamLine, omit?: PlotLoad) => PlotModel;
36
+ /** The point force at line position `at`: on a member or at a node. */
37
+ export declare const pointLoadAt: (model: PlotModel, line: BeamLine, at: number) => PlotLoad | undefined;
38
+ /**
39
+ * The outline of a row's diagram in px. `sx` maps line x (m) and `sy` a value to screen; a step at a
40
+ * break is the straight vertical between the two pieces. `close` returns to the axis at both ends.
41
+ */
42
+ export declare const rowOutline: (pw: Piecewise, sx: (x: number) => number, sy: (v: number) => number, close: boolean) => string;
43
+ /** Ordinates from the axis to the outline, `spacing` px apart: the hatching across the beam. */
44
+ export declare const rowOrdinates: (pw: Piecewise, sx: (x: number) => number, sy: (v: number) => number, spacing: number) => string;
45
+ /** The value range a row is scaled to: the diagram's own, always including zero. */
46
+ export declare const rowRange: (pw: Piecewise) => [number, number];
47
+ export interface RowPeak {
48
+ readonly x: number;
49
+ readonly value: number;
50
+ readonly side: Side;
51
+ readonly kind: 'max' | 'min';
52
+ }
53
+ /** The largest and smallest values worth writing on a row: both, when each is a real share of the row. */
54
+ export declare const rowPeaks: (pw: Piecewise) => RowPeak[];
55
+ /** Where the result breaks: supports, joints and point loads - the places the cursor snaps to. */
56
+ export declare const rowBreaks: (pw: Piecewise) => number[];
@@ -0,0 +1,86 @@
1
+ /**
2
+ * The drawing of a whole structure as scene items, in the hand of the EduBeam website's figures
3
+ * (HeroFigure, BuildSteps): ink members with round caps, outlined supports, orange loads, purple
4
+ * reactions clear of the supports, diagrams as an outline with ordinates across the member, and
5
+ * numbers where a reader looks for them - member ends, steps, extremes and corners.
6
+ *
7
+ * Sign rules follow the EduBeam app: N and V positive away from the member's local +z side, M on
8
+ * the tension side, so a sagging moment hangs below a beam drawn left to right.
9
+ */
10
+ import { type InternalForce, type MemberFrame, type MemberResults, type PlotModel } from './model.js';
11
+ import { type Anchor, type SceneItem, type TextPlacement } from './scene.js';
12
+ import { type Units } from './units.js';
13
+ /** What the caller switches on and off. Results are named by their symbol. */
14
+ export type PlotLayer = 'nodes' | 'nodeLabels' | 'dimensions' | 'members' | 'supports' | 'loads' | 'reactions' | 'N' | 'V' | 'M' | 'w';
15
+ /** Every layer, in paint order: results under the structure, nodes on top as BuildSteps draws them. */
16
+ export declare const PLOT_LAYERS: readonly PlotLayer[];
17
+ export interface TemperatureSymbols {
18
+ /** The uniform change, along the axis */
19
+ readonly uniform: string;
20
+ /** The difference across the depth, bottom minus top */
21
+ readonly gradient: string;
22
+ }
23
+ export declare const DEFAULT_TEMPERATURE_SYMBOLS: TemperatureSymbols;
24
+ export declare const RESULT_LAYERS: readonly ["N", "V", "M", "w"];
25
+ export type ResultLayer = (typeof RESULT_LAYERS)[number];
26
+ export interface StructureSceneOptions {
27
+ /** Layers to build. Build every layer that may be shown, so the layout never moves. */
28
+ readonly layers: ReadonlySet<PlotLayer>;
29
+ /** Thumbnail drawing: smaller symbols, at most two values per member, magnitudes only. */
30
+ readonly compact: boolean;
31
+ readonly units: Units;
32
+ readonly numberFormat?: Intl.NumberFormat;
33
+ /** The temperature load's symbols, which apps write differently: the Czech EduBeam has ΔTs and ΔTd − ΔTh. */
34
+ readonly temperatureSymbols?: TemperatureSymbols;
35
+ /** Current scale in px per metre: spaces ordinates and load arrows evenly on screen. */
36
+ readonly scale: number;
37
+ /** Largest diagram ordinate, px. */
38
+ readonly diagramSize: number;
39
+ /** Largest displacement on the deformed shape, px. */
40
+ readonly deformedSize: number;
41
+ /** Fixed px per SI unit for a result, to draw several plots at one scale. */
42
+ readonly diagramScale?: Partial<Record<ResultLayer, number>>;
43
+ /** M on the tension side (most of Europe); off draws it on the compression side. */
44
+ readonly momentOnTensionSide: boolean;
45
+ /** The plot's font size, px: labels in a tight spot may step down from it to 10 px. */
46
+ readonly fontSize?: number;
47
+ /** Values upright (`horizontal`) or turned to run along their ordinate (`axis`), as in the app. */
48
+ readonly resultLabelMode?: ResultLabelMode;
49
+ /**
50
+ * `values` (the default) draws each reaction the way it acts, with its size. `names` draws the
51
+ * unknowns of an exercise instead: an arrow for every restrained direction, pointing the way it
52
+ * counts as positive (along the node's x, up, counter-clockwise), named `A` with subscript `x`,
53
+ * `z`, or `M` with subscript `A`. It needs no results.
54
+ */
55
+ readonly reactionLabels?: ReactionLabels;
56
+ }
57
+ export type ResultLabelMode = 'axis' | 'horizontal';
58
+ export type ReactionLabels = 'values' | 'names';
59
+ /** Ordinates are this far apart on screen, as in the app and the website's figures. */
60
+ export declare const HATCH_SPACING_PX = 7;
61
+ type Vec = {
62
+ readonly x: number;
63
+ readonly y: number;
64
+ };
65
+ /** Which way a positive value is drawn, along the member's local z: +1 toward local +z. */
66
+ export declare const diagramSide: (q: InternalForce, momentOnTensionSide: boolean) => 1 | -1;
67
+ /**
68
+ * Where a value goes: just beyond the tip of the ordinate it denotes, along that ordinate, so it
69
+ * reads as the ordinate's continuation. With `axis` the text turns to run along the ordinate
70
+ * (across the member), as the app writes it, never upside down. Each further place moves it
71
+ * outward along the same ordinate - it never leaves its tip.
72
+ */
73
+ export declare const tipPlacements: (tip: Anchor, out: Vec, mode: ResultLabelMode, gaps?: number[]) => TextPlacement[];
74
+ /** Every member carries one constant normal force and no member loads: a truss, read bar by bar. */
75
+ export declare const isBarStructure: (model: PlotModel, results: Readonly<Record<string, MemberResults>>) => boolean;
76
+ /** px per SI unit for each result, from the largest value anywhere in the structure. */
77
+ export declare const diagramScales: (model: PlotModel, options: Pick<StructureSceneOptions, "diagramSize" | "deformedSize" | "diagramScale">) => Record<ResultLayer, number>;
78
+ export declare const memberFrames: (model: PlotModel) => Map<string, MemberFrame>;
79
+ /**
80
+ * The result a thumbnail shows when none is asked for: the moment for beams and frames, the
81
+ * normal force for a truss (every member pinned, or bending negligible beside the axial forces),
82
+ * the deformed shape when nothing carries a force (a free temperature load).
83
+ */
84
+ export declare const defaultResultLayer: (model: PlotModel) => ResultLayer | null;
85
+ export declare const buildStructureScene: (model: PlotModel, options: StructureSceneOptions) => SceneItem[];
86
+ export {};