Skip to content

Commit 994e034

Browse files
Ink Open Sourcecopybara-github
authored andcommitted
Remove unused geometry_internal::SpiralLerp function
PiperOrigin-RevId: 827593574
1 parent 74d55df commit 994e034

File tree

3 files changed

+0
-78
lines changed

3 files changed

+0
-78
lines changed

ink/geometry/internal/algorithms.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ std::optional<std::array<float, 3>> GetBarycentricCoordinates(
5151
return std::array<float, 3>({b0, b1, 1 - b0 - b1});
5252
}
5353

54-
Vec SpiralLerp(Vec a, Vec b, float t) {
55-
if (t == 0) return a;
56-
if (t == 1) return b;
57-
58-
Angle direction = a.Direction() + t * Vec::SignedAngleBetween(a, b);
59-
// Note that magnitude can lerp to a negative value, which evaluates to the
60-
// desired reflection through the origin.
61-
float magnitude = (1 - t) * a.Magnitude() + t * b.Magnitude();
62-
return Vec::FromDirectionAndMagnitude(direction, magnitude);
63-
}
64-
6554
Envelope CalculateEnvelope(const MutableMesh& mesh) {
6655
Envelope envelope;
6756
for (uint32_t i = 0; i < mesh.VertexCount(); ++i) {

ink/geometry/internal/algorithms.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,6 @@ namespace ink::geometry_internal {
4242
std::optional<std::array<float, 3>> GetBarycentricCoordinates(
4343
const Triangle& triangle, Point position);
4444

45-
// Interpolates from `a` to `b` by separately interpolating or extrapolating
46-
// the direction and magnitude based on the parameter `t`.
47-
//
48-
// * When `a` and `b` have different magnitudes and directions, this produces
49-
// points on an Archimedean spiral containing `a`, `b`, and the origin.
50-
// * When `a` and `b` have the same direction, this is equivalent to a regular
51-
// linear interpolation or extrapolation. This is a degenerate spiral with
52-
// infinite radial separation between loops.
53-
// * When `a` and `b` have the same magnitude, this is equivalent to the 2D
54-
// case of spherical interpolation (https://en.wikipedia.org/wiki/Slerp).
55-
// This is a degenerate spiral with zero radial separation between loops.
56-
Vec SpiralLerp(Vec a, Vec b, float t);
57-
5845
// Returns the `Envelope` of `mesh` positions.
5946
//
6047
// Vertex positions contribute to the envelope by just being in the `mesh` and

ink/geometry/internal/algorithms_test.cc

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -108,60 +108,6 @@ TEST(GetBarycentricCoordinatesTest, DegenerateTriangle) {
108108
Eq(std::nullopt));
109109
}
110110

111-
TEST(SpiralLerpTest, NonZeroInputVectorsWithDifferentDirections) {
112-
EXPECT_THAT(SpiralLerp({4, 0}, {0, 5}, -5), VecNear({0, 1}, 0.001));
113-
EXPECT_THAT(SpiralLerp({4, 0}, {0, 5}, -4), VecNear({0, 0}, 0.001));
114-
EXPECT_THAT(SpiralLerp({4, 0}, {0, 5}, -1), VecNear({0, -3}, 0.001));
115-
EXPECT_THAT(SpiralLerp({4, 0}, {0, 5}, 0), VecEq({4, 0}));
116-
EXPECT_THAT(
117-
SpiralLerp({4, 0}, {0, 5}, 0.5),
118-
VecNear(Vec::FromDirectionAndMagnitude(kFullTurn / 8, 4.5), 0.001));
119-
EXPECT_THAT(SpiralLerp({4, 0}, {0, 5}, 1), VecEq({0, 5}));
120-
EXPECT_THAT(SpiralLerp({4, 0}, {0, 5}, 3), VecNear({0, -7}, 0.001));
121-
122-
EXPECT_THAT(SpiralLerp({4, 0}, {0, -3}, -1), VecNear({0, 5}, 0.001));
123-
EXPECT_THAT(SpiralLerp({4, 0}, {0, -3}, 0), VecEq({4, 0}));
124-
EXPECT_THAT(
125-
SpiralLerp({4, 0}, {0, -3}, 0.5),
126-
VecNear(Vec::FromDirectionAndMagnitude(-kFullTurn / 8, 3.5), 0.001));
127-
EXPECT_THAT(SpiralLerp({4, 0}, {0, -3}, 1), VecEq({0, -3}));
128-
EXPECT_THAT(SpiralLerp({4, 0}, {0, -3}, 4), VecNear({0, 0}, 0.001));
129-
EXPECT_THAT(SpiralLerp({4, 0}, {0, -3}, 5), VecNear({0, 1}, 0.001));
130-
}
131-
132-
TEST(SpiralLerpTest, NonZeroInputVectorsWithSameDirection) {
133-
EXPECT_THAT(SpiralLerp({1, 1}, {3, 3}, -1), VecNear({-1, -1}, 0.001));
134-
EXPECT_THAT(SpiralLerp({1, 1}, {3, 3}, 0), VecEq({1, 1}));
135-
EXPECT_THAT(SpiralLerp({1, 1}, {3, 3}, 0.5), VecNear({2, 2}, 0.001));
136-
EXPECT_THAT(SpiralLerp({1, 1}, {3, 3}, 1), VecEq({3, 3}));
137-
EXPECT_THAT(SpiralLerp({1, 1}, {3, 3}, 2), VecNear({5, 5}, 0.001));
138-
}
139-
140-
TEST(SpiralLerpTest, ZeroInputVectors) {
141-
// Note that the "direction" of (0, 0) is toward the positive x-axis as given
142-
// by IEEE atan2.
143-
144-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 2}, -1), VecNear({0, 2}, 0.001));
145-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 2}, 0), VecEq({0, 0}));
146-
EXPECT_THAT(
147-
SpiralLerp({0, 0}, {0, 2}, 0.75),
148-
VecNear(Vec::FromDirectionAndMagnitude(3 * kFullTurn / 16, 1.5), 0.001));
149-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 2}, 1), VecEq({0, 2}));
150-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 2}, 2), VecNear({-4, 0}, 0.001));
151-
152-
EXPECT_THAT(SpiralLerp({-3, 0}, {0, 0}, -1), VecNear({6, 0}, 0.001));
153-
EXPECT_THAT(SpiralLerp({-3, 0}, {0, 0}, 0), VecEq({-3, 0}));
154-
EXPECT_THAT(SpiralLerp({-3, 0}, {0, 0}, 0.5), VecNear({0, -1.5}, 0.001));
155-
EXPECT_THAT(SpiralLerp({-3, 0}, {0, 0}, 1), VecEq({0, 0}));
156-
EXPECT_THAT(SpiralLerp({-3, 0}, {0, 0}, 2), VecNear({3, 0}, 0.001));
157-
158-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 0}, -1), VecEq({0, 0}));
159-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 0}, 0), VecEq({0, 0}));
160-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 0}, 0.2), VecEq({0, 0}));
161-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 0}, 1), VecEq({0, 0}));
162-
EXPECT_THAT(SpiralLerp({0, 0}, {0, 0}, 2), VecEq({0, 0}));
163-
}
164-
165111
TEST(CalculateEnvelopeTest, EmptyMesh) {
166112
MutableMesh mesh;
167113
EXPECT_TRUE(CalculateEnvelope(mesh).IsEmpty());

0 commit comments

Comments
 (0)