jzy3d / jzy3d-api

A Java API for 3d and 2d charts
BSD 3-Clause "New" or "Revised" License
282 stars 145 forks source link

Added Arrow class #280

Closed jzy3d closed 2 years ago

jzy3d commented 2 years ago

image

Made with

{
    Arrow arrow = new Arrow();
    arrow.setWireframeDisplayed(false);
    arrow.setData(createVector3d(Coord3d.ORIGIN, Coord3d.IDENTITY, 0.2f), 0.02f, 10, 0, Color.RED);
    arrow.setReflectLight(true);

    chart.getScene().getGraph().add(arrow);
    chart.addLightOnCamera();
  }

  private static Vector3d createVector3d(Coord3d pos, Coord3d dir, float length) {
    Coord3d dirN = dir.getNormalizedTo(length / 2f);
    Coord3d end = pos.add(dirN);
    dirN = dirN.negative();
    Coord3d start = pos.add(dirN);
    return new Vector3d(start, end);
  }