UNPKG

5.21 kBTypeScriptView Raw
1import { Point, PvjsonNode, AttachablePoint, Orientation, PvjsonEdge, StartSegmentDetailsMap, Side } from "./gpml2pvjson";
2export declare const START_SIDE_TO_ORIENTATION_MAP: {
3 right: number[];
4 bottom: number[];
5 left: number[];
6 top: number[];
7};
8export declare const START_SIDE_TO_EMANATION_ANGLE_MAPPINGS: any;
9export declare const EMANATION_ANGLE_TO_START_SIDE_MAPPINGS: any;
10export declare const START_SEGMENT_DETAILS_MAPS: StartSegmentDetailsMap[];
11export interface ISmartPoint {
12 x: number;
13 y: number;
14 curve?: any;
15 moveTo?: any;
16 orientation?: Orientation;
17}
18export declare class SmartPoint implements ISmartPoint {
19 x: number;
20 y: number;
21 curve?: any;
22 moveTo?: any;
23 orientation?: Orientation;
24 constructor(point: ISmartPoint);
25 angle: () => number;
26 fromArray: ([x, y]: [number, number]) => void;
27 toArray: () => number[];
28}
29export declare class SmartVector {
30 angle: number;
31 p0: SmartPoint;
32 p1: SmartPoint;
33 constructor(p0: ISmartPoint, p1: ISmartPoint);
34 angleDistance: (vector2: any) => number;
35}
36export declare class SmartPath {
37 points: SmartPoint[];
38 sum: SmartVector;
39 path: any;
40 constructor(points: ISmartPoint[], edge?: any);
41 position: (scalar: number, accuracy?: number) => {
42 x: any;
43 y: any;
44 angle: number;
45 };
46}
47export declare function addAngles(angle1: number, angle2: number): number;
48export declare function crossProduct(u: [number, number], v: [number, number]): number;
49export declare function flipOrientation(orientation: Orientation): number[];
50export declare function flipSide(side: Side): Side;
51export declare function getMinimumAngleBetweenVectors(vectorDirectionAngle1: number, vectorDirectionAngle2: number): number;
52export declare function getAngleOfEmanationFromPoint(point: AttachablePoint): number;
53export declare function reverseAngle(angle: any): number;
54export declare function getAngleAtPoint(edge: PvjsonEdge, positionX: number): number;
55export declare function getAngleFromPointToPoint({x: x0, y: y0}: {
56 x: any;
57 y: any;
58}, {x: x1, y: y1}: {
59 x: any;
60 y: any;
61}): number;
62export declare function getStartSideByOrientation([orientationX, orientationY]: Orientation): Side;
63/**
64 * Calculate the inverse matrix.
65 * @returns {Matrix}
66 */
67export declare function invertMatrix(M: any): any[];
68export declare function multiplyMatrices(m1: any, m2: any): any[];
69/**
70 * rotate
71 *
72 * @param theta (float): rotation angle in radians, measured clockwise
73 * @return transformation matrix for rotation
74 *
75 * Note that for Canvas and SVG, the y axis points down:
76 *
77 * *---------> x
78 * |
79 * |
80 * |
81 * v
82 *
83 * y
84 *
85 * The transformation matrix returned takes this into account and is intentionally
86 * different from the transformation matrix that would be returned if the y-axis
87 * pointed up, as is common in many math classes.
88 */
89export declare function rotate(theta: number): [[number, number, 0], [number, number, 0], [0, 0, 1]];
90export declare function scale([xScale, yScale]: [number, number]): [[number, 0, 0], [0, number, 0], [0, 0, 1]];
91export declare function translate([xTranslation, yTranslation]: [number, number]): [[1, 0, number], [0, 1, number], [0, 0, 1]];
92export declare function getTransformationMatrix(transformationSequence: any): number[][];
93export declare function multiplyMatrixByVector(transformationMatrix: any, vector: any): number[][];
94/**
95 * sameSide
96 *
97 * Calculate whether the current edge's second point, a, (end of first segment)
98 * and its final point, b, are both on the same side of the referenced edge.
99 *
100 * current edge: pipes/hyphens
101 * referenced edge: dots
102 *
103 * Example of True
104 *
105 * p1
106 * .
107 * .
108 * *------------a
109 * . |
110 * . |
111 * . |
112 * . |
113 * . |
114 * . |
115 * . |
116 * . |
117 * . |
118 * . |
119 * . *-----b
120 * .
121 * .
122 * p2
123 *
124 *
125 * Example of False
126 *
127 * p1
128 * .
129 * *------------a
130 * . |
131 * . |
132 * . |
133 * . |
134 * . |
135 * .|
136 * |.
137 * | .
138 * | .
139 * | .
140 * *-----b .
141 * .
142 * p2
143 *
144 *
145 * @param {Object} p1 - first point of the referenced edge
146 * @param {Object} p2 - last point of the referenced edge
147 * @param {Object} a - last point of the first segment of the current edge (the point following the start point)
148 * @param {Object} b - point where the current edge ends
149 * @return {Boolean) - whether the last point of the first segment of the current edge is on the same side as the last point of the current edge
150 */
151export declare function sameSide(p1: Point, p2: Point, a: Point, b: Point): boolean;
152export declare function transform({element, transformOrigin, transformationSequence}: {
153 element: PvjsonNode;
154 transformOrigin?: string;
155 transformationSequence?: any[];
156}): PvjsonNode;