UNPKG

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