Skip to content

Commit

Permalink
feat(utils): add utility function to move vehicle reference position (#…
Browse files Browse the repository at this point in the history
…374)

* feat(utils): provide utility to move vehicle position from center to front bumper
* feat: happy new year 2024
* clean(utils): rename to VehicleReferenceUtils, completed set of methods
  • Loading branch information
kschrab authored Jan 23, 2024
1 parent f0f5538 commit 7430df8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
12 changes: 12 additions & 0 deletions legal/templates/license-header-2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved.

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0

SPDX-License-Identifier: EPL-2.0

Contact: [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved.
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contact: [email protected]
*/

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;

/**
* 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.
*/
public static Vector3d fromCenterToFrontBumper(Vector3d pos, double heading, double length) {
return VectorUtils.getDirectionVectorFromHeading(heading, new Vector3d()).multiply(length / 2).add(pos);
}

/**
* 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();
}

/**
* Moves the position reference of a vehicle from its center to the center of the front bumper.
*/
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);
}

/**
* Moves the position reference of a vehicle from the center of the front bumper to its bounding box center.
*/
public static CartesianPoint fromFrontBumperToCenter(CartesianPoint pos, double heading, double length) {
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();
}

}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@
<header>${parent.dir}/legal/templates/license-header-2021.txt</header>
<header>${parent.dir}/legal/templates/license-header-2022.txt</header>
<header>${parent.dir}/legal/templates/license-header-2023.txt</header>
<header>${parent.dir}/legal/templates/license-header-2024.txt</header>
</validHeaders>
<headerDefinitions>
</headerDefinitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected MosaicSimulation createSimulation() {

protected void printVersionAndCopyrightInfo() {
System.out.println("Eclipse MOSAIC [Version " + MosaicVersion.get().toString() + "]");
System.out.println("Copyright (c) 2023 Fraunhofer FOKUS and others. All rights reserved.");
System.out.println("Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved.");
System.out.println("License EPL-2.0: Eclipse Public License Version 2 [https://eclipse.org/legal/epl-v20.html].");
System.out.println();
}
Expand Down

0 comments on commit 7430df8

Please sign in to comment.