@edubeam/plot 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +33 -0
- package/LICENSE +674 -0
- package/README.md +386 -2
- package/dist/components/DiagramStack.vue.d.ts +18 -0
- package/dist/components/StructurePlot.vue.d.ts +19 -0
- package/dist/components/theme.d.ts +16 -0
- package/dist/components/types.d.ts +107 -0
- package/dist/core/fromSolver.d.ts +12 -0
- package/dist/core/model.d.ts +135 -0
- package/dist/core/polynomial.d.ts +72 -0
- package/dist/core/readout.d.ts +31 -0
- package/dist/core/scene.d.ts +225 -0
- package/dist/core/stack.d.ts +56 -0
- package/dist/core/structure.d.ts +67 -0
- package/dist/core/supports.d.ts +50 -0
- package/dist/core/units.d.ts +30 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +2883 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +6 -0
- package/package.json +90 -4
|
@@ -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,31 @@
|
|
|
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 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
|
+
}
|
|
23
|
+
/** The results at x, snapping to a break within `snap` metres so a step shows both its values. */
|
|
24
|
+
export declare const readMember: (results: MemberResults, x: number, snap?: number) => {
|
|
25
|
+
x: number;
|
|
26
|
+
values: Record<ReadoutQuantity, SidedValue>;
|
|
27
|
+
};
|
|
28
|
+
/** The member nearest the screen point (px, py), within `reach` px, and its results there. */
|
|
29
|
+
export declare const readoutAt: (model: PlotModel, t: Transform, px: number, py: number, reach: number) => Readout | null;
|
|
30
|
+
/** "M = 54 kNm", or "V = 13.3 → −6.7 kN" across a step. */
|
|
31
|
+
export declare const formatReadout: (r: Readout, q: ReadoutQuantity, units: Units, format?: Intl.NumberFormat) => string;
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
/** Drawn on from start to end when it appears; the number staggers members one after another. */
|
|
70
|
+
readonly draw?: number;
|
|
71
|
+
}
|
|
72
|
+
export type TextAlign = 'start' | 'middle' | 'end';
|
|
73
|
+
export type TextBaseline = 'top' | 'middle' | 'bottom';
|
|
74
|
+
/** Where a label sits: the point it hangs from and how it is aligned there. */
|
|
75
|
+
export interface TextPlacement {
|
|
76
|
+
readonly at: Anchor;
|
|
77
|
+
readonly align: TextAlign;
|
|
78
|
+
readonly baseline: TextBaseline;
|
|
79
|
+
/** A shorter wording (a value without its unit) for a tight spot. */
|
|
80
|
+
readonly text?: string;
|
|
81
|
+
/** A smaller font, px, for a tight spot. */
|
|
82
|
+
readonly size?: number;
|
|
83
|
+
/** Clockwise turn, degrees. */
|
|
84
|
+
readonly rotate?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface SceneText extends SceneBase {
|
|
87
|
+
readonly kind: 'text';
|
|
88
|
+
readonly layer: LayerIndex;
|
|
89
|
+
readonly at: Anchor;
|
|
90
|
+
readonly text: string;
|
|
91
|
+
readonly tone: Tone;
|
|
92
|
+
readonly align: TextAlign;
|
|
93
|
+
readonly baseline: TextBaseline;
|
|
94
|
+
/** Higher wins when two labels would overlap; the other is left out. */
|
|
95
|
+
readonly priority: number;
|
|
96
|
+
/** Clockwise turn, degrees. */
|
|
97
|
+
readonly rotate?: number;
|
|
98
|
+
readonly italic?: boolean;
|
|
99
|
+
readonly weight?: number;
|
|
100
|
+
/** Font size, px; the plot's own when left out. */
|
|
101
|
+
readonly size?: number;
|
|
102
|
+
/** Other places to try, in order, when the first is taken. */
|
|
103
|
+
readonly alternatives?: readonly TextPlacement[];
|
|
104
|
+
}
|
|
105
|
+
export interface SceneCircle extends SceneBase {
|
|
106
|
+
readonly kind: 'circle';
|
|
107
|
+
readonly layer: LayerIndex;
|
|
108
|
+
readonly at: Anchor;
|
|
109
|
+
readonly r: number;
|
|
110
|
+
readonly tone: Tone;
|
|
111
|
+
readonly width: number;
|
|
112
|
+
readonly fill: 'paper' | 'tone';
|
|
113
|
+
}
|
|
114
|
+
export type SceneItem = ScenePath | SceneText | SceneCircle;
|
|
115
|
+
export declare const anchor: (x: number, z: number, dx?: number, dy?: number) => Anchor;
|
|
116
|
+
export declare const shift: (a: Anchor, dx: number, dy: number) => Anchor;
|
|
117
|
+
/** Screen transform: px = tx + s·x + dx, py = ty + s·z + dy. */
|
|
118
|
+
export interface Transform {
|
|
119
|
+
readonly s: number;
|
|
120
|
+
readonly tx: number;
|
|
121
|
+
readonly ty: number;
|
|
122
|
+
}
|
|
123
|
+
export declare const project: (t: Transform, a: Anchor) => [number, number];
|
|
124
|
+
export declare const textWidth: (text: string, size: number) => number;
|
|
125
|
+
/** The text's box around its anchor, before any rotation, in px. */
|
|
126
|
+
export declare const textBox: (text: string, size: number, align: TextAlign, baseline: TextBaseline) => {
|
|
127
|
+
x0: number;
|
|
128
|
+
x1: number;
|
|
129
|
+
y0: number;
|
|
130
|
+
y1: number;
|
|
131
|
+
};
|
|
132
|
+
/** Where the baseline goes for each vertical alignment, as a share of the font size. */
|
|
133
|
+
export declare const BASELINE_SHIFT: Record<TextBaseline, number>;
|
|
134
|
+
export interface Bounds {
|
|
135
|
+
minX: number;
|
|
136
|
+
maxX: number;
|
|
137
|
+
minY: number;
|
|
138
|
+
maxY: number;
|
|
139
|
+
}
|
|
140
|
+
/** The screen box of a text item at transform t, rotation included. */
|
|
141
|
+
export declare const textBounds: (item: SceneText, t: Transform, fontSize: number) => Bounds;
|
|
142
|
+
/** Everything the scene paints, at scale s with no translation. */
|
|
143
|
+
export declare const sceneBounds: (items: readonly SceneItem[], s: number, fontSize: number) => Bounds;
|
|
144
|
+
export interface FitBox {
|
|
145
|
+
/** Available width, px. */
|
|
146
|
+
readonly width: number;
|
|
147
|
+
/** Fixed height, px; leave out to size the height to the content. */
|
|
148
|
+
readonly height?: number;
|
|
149
|
+
/** Upper bound for an automatic height. */
|
|
150
|
+
readonly maxHeight?: number;
|
|
151
|
+
readonly padding: number;
|
|
152
|
+
readonly fontSize: number;
|
|
153
|
+
}
|
|
154
|
+
export interface Fit extends Transform {
|
|
155
|
+
readonly width: number;
|
|
156
|
+
readonly height: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The largest scale at which everything fits the box, centred in it. Width and height grow with
|
|
160
|
+
* the scale like the maximum of linear functions, so the feasible scales are an interval from zero
|
|
161
|
+
* and bisection finds its end.
|
|
162
|
+
*/
|
|
163
|
+
export declare const fitScene: (items: readonly SceneItem[], box: FitBox) => Fit;
|
|
164
|
+
export interface ResolvedPath {
|
|
165
|
+
readonly group: string;
|
|
166
|
+
readonly d: string;
|
|
167
|
+
readonly layer: LayerIndex;
|
|
168
|
+
readonly tone: Tone;
|
|
169
|
+
readonly width: number;
|
|
170
|
+
readonly fill?: 'tone' | 'paper';
|
|
171
|
+
readonly fillOpacity?: number;
|
|
172
|
+
readonly opacity?: number;
|
|
173
|
+
readonly dash?: string;
|
|
174
|
+
readonly cap?: 'round' | 'butt';
|
|
175
|
+
readonly draw?: number;
|
|
176
|
+
}
|
|
177
|
+
export interface ResolvedText {
|
|
178
|
+
readonly group: string;
|
|
179
|
+
readonly x: number;
|
|
180
|
+
readonly y: number;
|
|
181
|
+
readonly text: string;
|
|
182
|
+
readonly tone: Tone;
|
|
183
|
+
readonly anchor: TextAlign;
|
|
184
|
+
readonly transform?: string;
|
|
185
|
+
readonly italic?: boolean;
|
|
186
|
+
readonly weight?: number;
|
|
187
|
+
readonly size?: number;
|
|
188
|
+
}
|
|
189
|
+
export interface ResolvedCircle {
|
|
190
|
+
readonly group: string;
|
|
191
|
+
readonly cx: number;
|
|
192
|
+
readonly cy: number;
|
|
193
|
+
readonly r: number;
|
|
194
|
+
readonly layer: LayerIndex;
|
|
195
|
+
readonly tone: Tone;
|
|
196
|
+
readonly width: number;
|
|
197
|
+
readonly fill: 'paper' | 'tone';
|
|
198
|
+
}
|
|
199
|
+
export interface ResolvedScene {
|
|
200
|
+
readonly paths: readonly ResolvedPath[];
|
|
201
|
+
readonly circles: readonly ResolvedCircle[];
|
|
202
|
+
readonly texts: readonly ResolvedText[];
|
|
203
|
+
}
|
|
204
|
+
export declare const pathData: (segments: readonly Segment[], t: Transform) => string;
|
|
205
|
+
/** Whether the segment p–q passes through the box (Liang-Barsky clipping). */
|
|
206
|
+
export declare const segmentHitsBox: (p: readonly [number, number], q: readonly [number, number], box: Bounds) => boolean;
|
|
207
|
+
export interface ResolveOptions {
|
|
208
|
+
readonly fontSize: number;
|
|
209
|
+
/** Labels must lie inside this box, px; ones that do not are left out. */
|
|
210
|
+
readonly viewport?: {
|
|
211
|
+
readonly width: number;
|
|
212
|
+
readonly height: number;
|
|
213
|
+
};
|
|
214
|
+
/** Labels that must be left out whatever room there is. */
|
|
215
|
+
readonly exclude?: ReadonlySet<SceneText>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Which labels to draw. By priority, a label is kept unless it would overlap one already kept,
|
|
219
|
+
* cross a member, or leave the viewport - so the figure never shows two numbers on top of each
|
|
220
|
+
* other or a number struck through by the structure.
|
|
221
|
+
*/
|
|
222
|
+
export declare const placeLabels: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => Map<SceneText, SceneText>;
|
|
223
|
+
/** Screen geometry for the scene, with the labels `placeLabels` keeps. */
|
|
224
|
+
export declare const resolveScene: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => ResolvedScene;
|
|
225
|
+
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,67 @@
|
|
|
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 only where a reader looks for them - 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 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 declare const RESULT_LAYERS: readonly ["N", "V", "M", "w"];
|
|
18
|
+
export type ResultLayer = (typeof RESULT_LAYERS)[number];
|
|
19
|
+
export interface StructureSceneOptions {
|
|
20
|
+
/** Layers to build. Build every layer that may be shown, so the layout never moves. */
|
|
21
|
+
readonly layers: ReadonlySet<PlotLayer>;
|
|
22
|
+
/** Thumbnail drawing: smaller symbols, at most two values per member, magnitudes only. */
|
|
23
|
+
readonly compact: boolean;
|
|
24
|
+
readonly units: Units;
|
|
25
|
+
readonly numberFormat?: Intl.NumberFormat;
|
|
26
|
+
/** Current scale in px per metre: spaces ordinates and load arrows evenly on screen. */
|
|
27
|
+
readonly scale: number;
|
|
28
|
+
/** Largest diagram ordinate, px. */
|
|
29
|
+
readonly diagramSize: number;
|
|
30
|
+
/** Largest displacement on the deformed shape, px. */
|
|
31
|
+
readonly deformedSize: number;
|
|
32
|
+
/** Fixed px per SI unit for a result, to draw several plots at one scale. */
|
|
33
|
+
readonly diagramScale?: Partial<Record<ResultLayer, number>>;
|
|
34
|
+
/** M on the tension side (most of Europe); off draws it on the compression side. */
|
|
35
|
+
readonly momentOnTensionSide: boolean;
|
|
36
|
+
/** The plot's font size, px: labels in a tight spot may step down from it to 10 px. */
|
|
37
|
+
readonly fontSize?: number;
|
|
38
|
+
/** Values upright (`horizontal`) or turned to run along their ordinate (`axis`), as in the app. */
|
|
39
|
+
readonly resultLabelMode?: ResultLabelMode;
|
|
40
|
+
}
|
|
41
|
+
export type ResultLabelMode = 'axis' | 'horizontal';
|
|
42
|
+
/** Ordinates are this far apart on screen, as in the app and the website's figures. */
|
|
43
|
+
export declare const HATCH_SPACING_PX = 7;
|
|
44
|
+
type Vec = {
|
|
45
|
+
readonly x: number;
|
|
46
|
+
readonly y: number;
|
|
47
|
+
};
|
|
48
|
+
/** Which way a positive value is drawn, along the member's local z: +1 toward local +z. */
|
|
49
|
+
export declare const diagramSide: (q: InternalForce, momentOnTensionSide: boolean) => 1 | -1;
|
|
50
|
+
/**
|
|
51
|
+
* Where a value goes: just beyond the tip of the ordinate it denotes, along that ordinate, so it
|
|
52
|
+
* reads as the ordinate's continuation. With `axis` the text turns to run along the ordinate
|
|
53
|
+
* (across the member), as the app writes it, never upside down. Each further place moves it
|
|
54
|
+
* outward along the same ordinate - it never leaves its tip.
|
|
55
|
+
*/
|
|
56
|
+
export declare const tipPlacements: (tip: Anchor, out: Vec, mode: ResultLabelMode, gaps?: number[]) => TextPlacement[];
|
|
57
|
+
/** px per SI unit for each result, from the largest value anywhere in the structure. */
|
|
58
|
+
export declare const diagramScales: (model: PlotModel, options: Pick<StructureSceneOptions, "diagramSize" | "deformedSize" | "diagramScale">) => Record<ResultLayer, number>;
|
|
59
|
+
export declare const memberFrames: (model: PlotModel) => Map<string, MemberFrame>;
|
|
60
|
+
/**
|
|
61
|
+
* The result a thumbnail shows when none is asked for: the moment for beams and frames, the
|
|
62
|
+
* normal force for a truss (every member pinned, or bending negligible beside the axial forces),
|
|
63
|
+
* the deformed shape when nothing carries a force (a free temperature load).
|
|
64
|
+
*/
|
|
65
|
+
export declare const defaultResultLayer: (model: PlotModel) => ResultLayer | null;
|
|
66
|
+
export declare const buildStructureScene: (model: PlotModel, options: StructureSceneOptions) => SceneItem[];
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Support symbols. Each restrained DOF combination has one symbol, drawn in screen pixels in a frame
|
|
3
|
+
* where +y points to the ground, then turned to suit the node: by a rotated support's axes, and away
|
|
4
|
+
* from the members that meet there.
|
|
5
|
+
*/
|
|
6
|
+
import type { Fixity, PlotModel, PlotNode } from './model.js';
|
|
7
|
+
export type SupportKind =
|
|
8
|
+
/** Dx, Dz and Ry held: a clamp. */
|
|
9
|
+
'fixed'
|
|
10
|
+
/** Dx and Dz held. */
|
|
11
|
+
| 'pin'
|
|
12
|
+
/** One translation held: Dz (rolls along x) or Dx (rolls along z). */
|
|
13
|
+
| 'roller'
|
|
14
|
+
/** One translation and the rotation held: slides along the free axis between two rails. */
|
|
15
|
+
| 'slider'
|
|
16
|
+
/** Only the rotation held. */
|
|
17
|
+
| 'rotation' | 'none';
|
|
18
|
+
export declare const supportKind: (f: Fixity) => SupportKind;
|
|
19
|
+
export type Point = readonly [number, number];
|
|
20
|
+
export interface GlyphPart {
|
|
21
|
+
readonly points: readonly Point[];
|
|
22
|
+
readonly closed?: boolean;
|
|
23
|
+
/** `bold` for the line the structure bears on, `thin` for hatching. */
|
|
24
|
+
readonly weight: 'thin' | 'regular' | 'bold';
|
|
25
|
+
/** Painted with the background, so the member does not show through a triangle. */
|
|
26
|
+
readonly fill?: 'paper';
|
|
27
|
+
}
|
|
28
|
+
export declare const supportGlyph: (kind: SupportKind) => readonly GlyphPart[];
|
|
29
|
+
export interface SupportPlacement {
|
|
30
|
+
readonly node: string;
|
|
31
|
+
readonly kind: SupportKind;
|
|
32
|
+
/** Clockwise turn of the glyph on screen, degrees. */
|
|
33
|
+
readonly rotation: number;
|
|
34
|
+
}
|
|
35
|
+
/** Sum of unit vectors from the node along each member that meets it. */
|
|
36
|
+
export declare const memberDirections: (model: PlotModel, node: PlotNode) => {
|
|
37
|
+
x: number;
|
|
38
|
+
z: number;
|
|
39
|
+
count: number;
|
|
40
|
+
};
|
|
41
|
+
/** The glyph's ground direction, (0, 1) turned by `rotation` degrees clockwise. */
|
|
42
|
+
export declare const groundDirection: (rotation: number) => {
|
|
43
|
+
x: number;
|
|
44
|
+
z: number;
|
|
45
|
+
};
|
|
46
|
+
export declare const supportPlacement: (model: PlotModel, node: PlotNode) => SupportPlacement;
|
|
47
|
+
/** An angle in (−180, 180]. */
|
|
48
|
+
export declare const normalizeDegrees: (deg: number) => number;
|
|
49
|
+
/** How far the turned glyph reaches from the node along the unit direction (x, z), in px. */
|
|
50
|
+
export declare const glyphReach: (kind: SupportKind, rotation: number, x: number, z: number) => number;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display units. Values stay SI everywhere else; a unit only says how to show one.
|
|
3
|
+
*/
|
|
4
|
+
export interface Unit {
|
|
5
|
+
readonly symbol: string;
|
|
6
|
+
/** Display value = SI value × scale (N → kN is 1e-3). */
|
|
7
|
+
readonly scale: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Units {
|
|
10
|
+
readonly force: Unit;
|
|
11
|
+
readonly moment: Unit;
|
|
12
|
+
readonly distributed: Unit;
|
|
13
|
+
readonly length: Unit;
|
|
14
|
+
readonly displacement: Unit;
|
|
15
|
+
readonly rotation: Unit;
|
|
16
|
+
readonly temperature: Unit;
|
|
17
|
+
}
|
|
18
|
+
export type UnitKind = keyof Units;
|
|
19
|
+
export declare const SI_UNITS: Units;
|
|
20
|
+
/** kN, kNm and mm: what structural engineering courses read. The default. */
|
|
21
|
+
export declare const KN_UNITS: Units;
|
|
22
|
+
export declare const resolveUnits: (units?: Partial<Units>) => Units;
|
|
23
|
+
/** One decimal, as the website's figures write their values. */
|
|
24
|
+
export declare const DEFAULT_NUMBER_FORMAT: Intl.NumberFormat;
|
|
25
|
+
/**
|
|
26
|
+
* The number alone, with a true minus sign, and no "-0" for a value that rounds to zero.
|
|
27
|
+
*/
|
|
28
|
+
export declare const formatNumber: (value: number, format?: Intl.NumberFormat) => string;
|
|
29
|
+
/** "36 kN": the SI value in the given unit. A narrow no-break space keeps the two together. */
|
|
30
|
+
export declare const formatQuantity: (si: number, unit: Unit, format?: Intl.NumberFormat) => string;
|