All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.ihmc.simulationconstructionset.util.ground.DoubleStepGroundProfile Maven / Gradle / Ivy

There is a newer version: 0.25.2
Show newest version
package us.ihmc.simulationconstructionset.util.ground;

import us.ihmc.euclid.geometry.BoundingBox3D;
import us.ihmc.euclid.tuple3D.interfaces.Vector3DBasics;

public class DoubleStepGroundProfile extends GroundProfileFromHeightMap
{
   private final BoundingBox3D boundingBox;

   private final double initialGroundXStep, finalGroundXStep, initialGroundZStep, finalGroundZStep;

   public DoubleStepGroundProfile(double yMin, double yMax, double initialElevationChangeX, double finalElevationChangeX, double initialElevationDifference,
                                  double finalElevationDifference)
   {
      double xMin = -1.0;
      double xMax = finalElevationChangeX + 10.0;

      initialGroundXStep = initialElevationChangeX;
      finalGroundXStep = finalElevationChangeX;
      initialGroundZStep = initialElevationDifference;
      finalGroundZStep = finalElevationDifference;

      double zMin = Double.NEGATIVE_INFINITY;
      double zMax = Math.max(0.0, Math.max(initialGroundZStep, finalGroundZStep)) + 0.01;
      boundingBox = new BoundingBox3D(xMin, yMin, zMin, xMax, yMax, zMax);
   }

   @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 < initialGroundXStep)
         return 0.0;
      else if (x < finalGroundXStep)
         return initialGroundZStep;
      else
         return finalGroundZStep;

   }

   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;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy