us.ihmc.simulationconstructionset.util.ground.StepUpGroundProfile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simulation-construction-set
Show all versions of simulation-construction-set
Simulation Construction Set
package us.ihmc.simulationconstructionset.util.ground;
import us.ihmc.euclid.geometry.BoundingBox3D;
import us.ihmc.euclid.tuple3D.interfaces.Point3DBasics;
import us.ihmc.euclid.tuple3D.interfaces.Vector3DBasics;
public class StepUpGroundProfile extends GroundProfileFromHeightMap
{
private final BoundingBox3D boundingBox;
private final double groundXStep;
private final double groundZStep;
public StepUpGroundProfile(double groundXStep, double groundZStep)
{
double xMin = -1.0;
double xMax = 4.0;
double yMin = -1.0;
double yMax = 1.0;
this.groundXStep = groundXStep;
this.groundZStep = groundZStep;
double zMin = Double.NEGATIVE_INFINITY;
double zMax = Double.POSITIVE_INFINITY;
boundingBox = new BoundingBox3D(xMin, yMin, zMin, xMax, yMax, zMax);
}
@Override
public void closestIntersectionAndNormalAt(double x, double y, double z, Point3DBasics intersection, Vector3DBasics normal)
{
closestIntersectionTo(x, y, z, intersection);
surfaceNormalAt(x, y, z, normal);
}
public void closestIntersectionTo(double x, double y, double z, Point3DBasics intersection)
{
intersection.set(x, y, heightAt(x, y, z));
}
@Override
public double heightAndNormalAt(double x, double y, double z, Vector3DBasics normalToPack)
{
double height = heightAt(x, y, z);
surfaceNormalAt(x, y, z, normalToPack);
return height;
}
@Override
public double heightAt(double x, double y, double z)
{
if (x > groundXStep)
return groundZStep;
return 0.0;
}
public void surfaceNormalAt(double x, double y, double z, Vector3DBasics normal)
{
normal.set(0.0, 0.0, 1.0);
}
@Override
public BoundingBox3D getBoundingBox()
{
return boundingBox;
}
}