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