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