Skip to content

Instantly share code, notes, and snippets.

@miho
Last active May 30, 2017 07:08
Show Gist options
  • Save miho/ee9139173ab2595d6711833e8ecdba01 to your computer and use it in GitHub Desktop.
Save miho/ee9139173ab2595d6711833e8ecdba01 to your computer and use it in GitHub Desktop.
VRL-Studio Component for plotting tangent lines
import edu.gcsc.vrl.jfreechart.TrajectoryPlotter;
import org.jfree.chart.JFreeChart;
@ComponentInfo(name="TangentLine", category="Custom")
public class TangentLine implements java.io.Serializable {
private static final long serialVersionUID=1L;
// plotter object
private transient TrajectoryPlotter plotter;
public JFreeChart tangentLine(
Trajectory t,
@ParamInfo(name="pos",
/* we request slider style for this integer */
style="slider",
/* invoke on change invokes the method whenever the slider position changes */
options="min=0;max=100;invokeOnChange=true" ) int pos
) {
// initialize plotter object
if(plotter==null) {
plotter = new TrajectoryPlotter();
}
// *** compute the tangent ***
Trajectory tangentLine = new Trajectory("Tangent Line");
// TODO add your code here
// plot both trajectories
return plotter.lineChart(t,tangentLine);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment