Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A YawPitchRoll enum #49

Open
calvertdw opened this issue Aug 2, 2022 · 0 comments
Open

A YawPitchRoll enum #49

calvertdw opened this issue Aug 2, 2022 · 0 comments

Comments

@calvertdw
Copy link
Member

Something like this which allows to make (UI stuff especially) abstract over yaw, pitch, and roll. These are often the gizmo handles or how you want to tell the chest to yaw, pitch, roll, etc..

public enum YawPitchRollAxis
{
   YAW(Axis3D.Z), PITCH(Axis3D.Y), ROLL(Axis3D.X);
   private final Axis3D axis3D;
   private final String lowerCasedName;
   private final String pascalCasedName;
   YawPitchRollAxis(Axis3D axis3D)
   {
      this.axis3D = axis3D;
      lowerCasedName = name().toLowerCase();
      pascalCasedName = StringUtils.capitalize(lowerCasedName);
   }
   public YawPitchRoll createYawPitchRoll(double angle)
   {
      YawPitchRoll yawPitchRoll = new YawPitchRoll();
      switch (this)
      {
         case YAW -> yawPitchRoll.setYaw(angle);
         case PITCH -> yawPitchRoll.setPitch(angle);
         case ROLL -> yawPitchRoll.setRoll(angle);
      }
      return yawPitchRoll;
   }
   private double getFromYawPitchRoll(YawPitchRollReadOnly yawPitchRollReadOnly)
   {
      return switch (this)
      {
         case YAW -> yawPitchRollReadOnly.getYaw();
         case PITCH -> yawPitchRollReadOnly.getPitch();
         case ROLL -> yawPitchRollReadOnly.getRoll();
      };
   }
   public Axis3D getAxis3D()
   {
      return axis3D;
   }
   public String getLowerCasedName()
   {
      return lowerCasedName;
   }
   public String getPascalCasedName()
   {
      return pascalCasedName;
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant