@vertexvis/geometry 0.20.1-testing.1 → 0.20.2-canary.1
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/dist/bundle.cjs.js +59 -0
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +59 -0
- package/dist/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.js +59 -0
- package/dist/cdn/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.min.js +2 -2
- package/dist/cdn/bundle.esm.min.js.map +1 -1
- package/dist/cdn/point.d.ts +21 -0
- package/dist/point.d.ts +21 -0
- package/package.json +3 -3
package/dist/bundle.esm.js
CHANGED
|
@@ -98,6 +98,60 @@ function scale$4(pt, scaleX, scaleY) {
|
|
|
98
98
|
y: pt.y * scaleY,
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
103
|
+
* factor.
|
|
104
|
+
*/
|
|
105
|
+
function scaleProportional(pt, scale) {
|
|
106
|
+
return {
|
|
107
|
+
x: pt.x * scale,
|
|
108
|
+
y: pt.y * scale,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the magnitude of a point.
|
|
113
|
+
*/
|
|
114
|
+
function magnitude$1(pt) {
|
|
115
|
+
return Math.sqrt(pt.x * pt.x + pt.y * pt.y);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Transforms a vector into the corresponding normal (unit) vector.
|
|
119
|
+
*/
|
|
120
|
+
function normalizeVector(pt) {
|
|
121
|
+
var magnitudeOfPoint = magnitude$1(pt);
|
|
122
|
+
if (magnitudeOfPoint === 0) {
|
|
123
|
+
return create$c(0, 0);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return scaleProportional(pt, 1 / magnitudeOfPoint);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns a new normal (unit) vector pointing between the two given points.
|
|
131
|
+
*/
|
|
132
|
+
function normalDirectionVector(ptA, ptB) {
|
|
133
|
+
return normalizeVector(subtract$1(ptB, ptA));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns a vector orthogonal to the vector between the two given points.
|
|
137
|
+
*/
|
|
138
|
+
function orthogonalVector(ptA, ptB) {
|
|
139
|
+
var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
|
|
140
|
+
// Handle vectors that are parallel to the x or y axis
|
|
141
|
+
if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
|
|
142
|
+
return create$c(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
|
|
143
|
+
}
|
|
144
|
+
if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
|
|
145
|
+
var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
|
|
146
|
+
var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
147
|
+
return normalizeVector(create$c(vectorXValue, vectorYValue));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
151
|
+
var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
|
|
152
|
+
return normalizeVector(create$c(vectorXValue, vectorYValue));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
101
155
|
/**
|
|
102
156
|
* Parses a JSON string representation of a Point and returns an object.
|
|
103
157
|
*
|
|
@@ -127,6 +181,11 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
127
181
|
lerp: lerp$1,
|
|
128
182
|
negate: negate$1,
|
|
129
183
|
scale: scale$4,
|
|
184
|
+
scaleProportional: scaleProportional,
|
|
185
|
+
magnitude: magnitude$1,
|
|
186
|
+
normalizeVector: normalizeVector,
|
|
187
|
+
normalDirectionVector: normalDirectionVector,
|
|
188
|
+
orthogonalVector: orthogonalVector,
|
|
130
189
|
fromJson: fromJson$4
|
|
131
190
|
});
|
|
132
191
|
|