Skip to content

Commit

Permalink
clean(utils): rename to VehicleReferenceUtils, completed set of methods
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Schrab <[email protected]>
  • Loading branch information
kschrab committed Jan 22, 2024
1 parent b4762c7 commit 0f95f4c
Showing 1 changed file with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
package org.eclipse.mosaic.lib.util;

import org.eclipse.mosaic.lib.geo.CartesianPoint;
import org.eclipse.mosaic.lib.geo.GeoPoint;
import org.eclipse.mosaic.lib.math.Vector3d;
import org.eclipse.mosaic.lib.math.VectorUtils;

public class VehicleUtils {
/**
* Utility class collecting methods to work with vehicle positions, such
* as converting the reference point from center to front bumper and vice versa.
*/
public class VehicleReferenceUtils {

/**
* Moves the position reference of a vehicle from its center to the center of the front bumper.
Expand All @@ -29,17 +34,23 @@ public static Vector3d fromCenterToFrontBumper(Vector3d pos, double heading, dou
}

/**
* Moves the position reference of a vehicle from the center of the front bumper to its bounding box center.
* Moves the position reference of a vehicle from its center to the center of the front bumper.
*/
public static Vector3d fromFrontBumperToCenter(Vector3d pos, double heading, double length) {
return VectorUtils.getDirectionVectorFromHeading(heading, new Vector3d()).multiply(-length / 2).add(pos);
public static CartesianPoint fromCenterToFrontBumper(CartesianPoint pos, double heading, double length) {
return fromCenterToFrontBumper(pos.toVector3d(), heading, length).toCartesian();
}

/**
* Moves the position reference of a vehicle from its center to the center of the front bumper.
*/
public static CartesianPoint fromCenterToFrontBumper(CartesianPoint pos, double heading, double length) {
return fromCenterToFrontBumper(pos.toVector3d(), heading, length).toCartesian();
public static GeoPoint fromCenterToFrontBumper(GeoPoint pos, double heading, double length) {
return fromCenterToFrontBumper(pos.toVector3d(), heading, length).toGeo();
}
/**
* Moves the position reference of a vehicle from the center of the front bumper to its bounding box center.
*/
public static Vector3d fromFrontBumperToCenter(Vector3d pos, double heading, double length) {
return VectorUtils.getDirectionVectorFromHeading(heading, new Vector3d()).multiply(-length / 2).add(pos);
}

/**
Expand All @@ -49,4 +60,11 @@ public static CartesianPoint fromFrontBumperToCenter(CartesianPoint pos, double
return fromFrontBumperToCenter(pos.toVector3d(), heading, length).toCartesian();
}

/**
* Moves the position reference of a vehicle from the center of the front bumper to its bounding box center.
*/
public static GeoPoint fromFrontBumperToCenter(GeoPoint pos, double heading, double length) {
return fromFrontBumperToCenter(pos.toVector3d(), heading, length).toGeo();
}

}

0 comments on commit 0f95f4c

Please sign in to comment.