public void Test_S2_Frames() { var z = new S2Point(0.2, 0.5, -3.3).Normalize(); var m = S2.GetFrame(z); Assert.True(S2.ApproxEquals(m.Col(2), z)); Assert.True(m.Col(0).IsUnitLength()); Assert.True(m.Col(1).IsUnitLength()); Assert2.DoubleEqual(m.Det(), 1); Assert.True(S2.ApproxEquals(S2.ToFrame(m, m.Col(0)), new(1, 0, 0))); Assert.True(S2.ApproxEquals(S2.ToFrame(m, m.Col(1)), new(0, 1, 0))); Assert.True(S2.ApproxEquals(S2.ToFrame(m, m.Col(2)), new(0, 0, 1))); Assert.True(S2.ApproxEquals(S2.FromFrame(m, new(1, 0, 0)), m.Col(0))); Assert.True(S2.ApproxEquals(S2.FromFrame(m, new(0, 1, 0)), m.Col(1))); Assert.True(S2.ApproxEquals(S2.FromFrame(m, new(0, 0, 1)), m.Col(2))); }
public void AddPoints(S2Cap index_cap, int num_points, TestIndex index) { int sqrt_num_points = (int)Math.Ceiling(Math.Sqrt(num_points)); S2PointVector3 frame = S2Testing.GetRandomFrameAt(index_cap.Center); double radius = index_cap.RadiusAngle().Radians; double spacing = 2 * radius / sqrt_num_points; for (int i = 0; i < sqrt_num_points; ++i) { for (int j = 0; j < sqrt_num_points; ++j) { S2Point point = new(Math.Tan((i + 0.5) * spacing - radius), Math.Tan((j + 0.5) * spacing - radius), 1.0); index.Add(S2.FromFrame(frame, point.Normalize()), i * sqrt_num_points + j); } } }