Skip to content

Commit

Permalink
Merge pull request #53 from Geodan/cleaning_code
Browse files Browse the repository at this point in the history
cleaning code
  • Loading branch information
bertt authored Jun 10, 2024
2 parents b545b3a + 9bf7f50 commit 50348e1
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 298 deletions.
23 changes: 0 additions & 23 deletions src/Cesium/Axis.cs

This file was deleted.

10 changes: 0 additions & 10 deletions src/Cesium/CesiumTransformer.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
using System;
using System.Numerics;
using Wkx;

namespace i3dm.export.Cesium;

public static class CesiumTransformer
{
public static double[] GetTransformer(Point p, decimal[] scale, double heading)
{
var center = SpatialConverter.GeodeticToEcef((double)p.X, (double)p.Y, (double)p.Z);
var GD_transform = SpatialConverter.EcefToEnu(center);
var transform = Flatten.Flattener(GD_transform, scale);
transform = Rotator.TransformRotateAroundZ(transform, heading);
return transform;
}

public static (Vector3 East, Vector3 Up) GetEastUp(Vector3 position, double rotation = 0)
{
var GD_transform = SpatialConverter.EcefToEnu(position);
Expand Down
37 changes: 0 additions & 37 deletions src/Cesium/Flatten.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/Cesium/SpatialConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ public static double[] ToWgs84FromSphericalMercator(double x, double y)
return new double[] { lon, lat };
}

public static Vector3 GeodeticToEcef(double lon, double lat, double alt)
{
var ellipsoid = new Ellipsoid();
double equatorialRadius = ellipsoid.SemiMajorAxis;
double eccentricity = ellipsoid.Eccentricity;
double latitudeRadians = Radian.ToRadius(lat);
double longitudeRadians = Radian.ToRadius(lon);
double altitudeRadians = alt;
double num = equatorialRadius / Math.Sqrt(1.0 - Math.Pow(eccentricity, 2.0) * Math.Pow(Math.Sin(latitudeRadians), 2.0));
double x = (num + altitudeRadians) * Math.Cos(latitudeRadians) * Math.Cos(longitudeRadians);
double y = (num + altitudeRadians) * Math.Cos(latitudeRadians) * Math.Sin(longitudeRadians);
double z = ((1.0 - Math.Pow(eccentricity, 2.0)) * num + altitudeRadians) * Math.Sin(latitudeRadians);
return new Vector3((float)x, (float)y, (float)z);
}

public static Matrix4x4 EcefToEnu(Vector3 position)
{
var east = new Vector3();
Expand Down
11 changes: 0 additions & 11 deletions src/Cesium/Transforms.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/DistanceCalculator.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/InstancesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using Wkx;

namespace i3dm.export;
Expand Down
78 changes: 0 additions & 78 deletions src/TileTransform.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Tileset/TilesetClasses.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace i3dm.export.Tileset;

Expand Down
46 changes: 0 additions & 46 deletions tests/Cesium/CesiumTransformerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,6 @@ namespace i3dm.export.tests.Cesium;

class CesiumTransformerTests
{
[Test]
public void TestCesiumTransformer1()
{
var lon = 4.8933281;
var lat = 52.3731013;

var p = new Wkx.Point(lon, lat, 0);

var globalTransform = CesiumTransformer.GetTransformer(p, new decimal[] { 1, 1, 1 }, 0);
}


[Test]
public void TestCesiumTransformer()
{
var lon = 5.139838;
var lat = 52.086577;

var p = new Wkx.Point(lon, lat, 0);

var globalTransform = CesiumTransformer.GetTransformer(p, new decimal[] { 1, 1, 1 }, 0);
var expectedTransform = new double[] {
-0.08958682417869568,
0.9959790110588074,
-1.5050178021509955E-16,
0.0,
-0.7857677936553955,
-0.07067863643169403,
0.6144700050354004,
0.0,
0.6119993329048157,
0.05504842475056648,
0.7889401912689209,
0.0,
3911573.0,
351840.15625,
5008728.5,
1.0
};

for (var i = 0; i < 16; i++)
{
Assert.That(globalTransform[i].Equals(expectedTransform[i]));
}
}

[Test]
public void TestGetEnuAnglesOnPosition()
{
Expand Down
37 changes: 0 additions & 37 deletions tests/Cesium/SpatialConvertorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,6 @@ public void TestMercatorProjection()
Assert.That(Math.Round(res1[1], 3) == Math.Round(lat, 3));
}

[Test]
public void EastNorthUpTesting()
{
// sample from https://community.cesium.com/t/bounding-box-calculations-in-3d-tiles/7901/3
var latRadians = 0.698858210;
var lonRadians = -1.3197004795898053;

var lat = latRadians / (Math.PI / 180);
var lon = lonRadians / (Math.PI / 180);
var center = SpatialConverter.GeodeticToEcef(lon, lat, 0);
Assert.That(center.X == 1214930.9913739867f);
Assert.That(center.Y == -4736396.825676652f);
Assert.That(center.Z == 4081525.0998436413f);

var GD_transform = SpatialConverter.EcefToEnu(center);

Assert.That(GD_transform.M11 == 0.9686407230533828f);
Assert.That(GD_transform.M12 == 0.248465583f);
Assert.That(GD_transform.M13 == 0);
Assert.That(GD_transform.M14 == 0);

Assert.That(GD_transform.M21 == -0.159848824f);
Assert.That(GD_transform.M22 == 0.6231691f);
Assert.That(GD_transform.M23 == 0.7655773f);
Assert.That(GD_transform.M24 == 0);

Assert.That(GD_transform.M31 == 0.190219611f);
Assert.That(GD_transform.M32 == -0.74156934f);
Assert.That(GD_transform.M33 == 0.6433439f);
Assert.That(GD_transform.M34 == 0);

Assert.That(GD_transform.M41 == center.X);
Assert.That(GD_transform.M42 == center.Y);
Assert.That(GD_transform.M43 == center.Z);
Assert.That(GD_transform.M44 == 1);
}

[Test]
public void TestEcefToEnu()
{
Expand Down
21 changes: 0 additions & 21 deletions tests/DistanceCalculatorTests.cs

This file was deleted.

0 comments on commit 50348e1

Please sign in to comment.