Skip to content

Commit

Permalink
V1.5
Browse files Browse the repository at this point in the history
Comes with its own parser.
No dependecies on any external libraries.
  • Loading branch information
babaissarkar committed Sep 5, 2021
1 parent a844bbf commit 67eddf4
Show file tree
Hide file tree
Showing 28 changed files with 1,292 additions and 276 deletions.
51 changes: 15 additions & 36 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,55 @@ <h1>ssplot</h1>

<h1>Requirements</h1>

<p>Any Java version less than 15. (and more than 6).</p>
<p>Any Java version >= 7.</p>

<h1>Installation</h1>

<ol>
<li>Install Java runtime (JRE). Version 14 preferred. Versions 15 and higher require some more work, which is explained in the last section. I use OpenJDK 14, which can be downloaded from <a href="https://jdk.java.net/java-se-ri/14">here</a>.</li>
<li>Download and install Apache Commons Math library (version 3) in your <code>CLASSPATH</code>. (Make sure it is installed in <code>/usr/share/java</code> for Linux, which is the case if it is installed by the package manager such as <code>apt</code>. You don't have to set the <code>CLASSPATH</code> for Linux. It is automatically done by the <code>ssplot</code> script.)</li>
<li>Install Java runtime (JRE).</li>
<li>Download the latest release of SSPlot from the releases section. (You can also clone this repository, either using <code>git clone</code> or using the Code menu in this page (Code -> Dropdown -> Download ZIP))</li>
<li>Extract the ZIP if you downloaded it.</li>
<li>Extract the ZIP.</li>
<li>Enter the folder inside the ZIP (or the cloned folder) and open a terminal there.</li>
<li>Run using <code>./ssplot</code> from your terminal/command line (For linux).</li>
<li>Alternatively, for other OSes, see the next section.</li>
<li>Run using <code>./ssplot-quick-run</code> from your terminal/command line (For linux), or go to the directory where the file <code>SSPlot.jar</code> is, open a terminal there and run <code>java -jar SSPlot.jar</code></li>
<li>Alternatively, for other OSes, see the section <strong>Other OSes</strong>.</li>
<li>You may need to set the <code>CLASSPATH</code> environment variable if you want to use an alternate engine for math equation parsing, as explained in a later section.</li>
</ol>

<h1>Short installation for Ubuntu</h1>

<ol>
<li>Install the dependencies. <code>sudo apt install openjdk-14-jre libcommons-math3-java</code></li>
<li>Get the zip file from the Releases section and install the deb file from it <code>sudo dpkg -i ssplot-1.4.1.deb</code></li>
<li>Install Java <code>sudo apt install default-jre</code>.</li>
<li>Get the zip file from the Releases section and install the deb file from it <code>sudo dpkg -i ssplot-1.5.deb</code></li>
<li>You can now run SSPlot from the terminal by using the command <code>ssplot</code>.</li>
</ol>

<h1>Other OSes.</h1>

<p>Steps are same, except that,</p>

<ol>
<li>You have to set the <code>CLASSPATH</code> yourself. You can search the internet for how to do that for your OS. Make sure that the <code>CLASSPATH</code> contains the Apache Commons Math library (version 3) and <code>SSPlot.jar</code>.</li>
<li>You may have to set the <code>CLASSPATH</code> yourself if you are using an external script engine. You can search the internet for how to do that for your OS. Make sure that the <code>CLASSPATH</code> contains the Apache Commons Math library (version 3) and <code>SSPlot.jar</code>. Not really needed as of version 1.5.</li>
<li>Make sure you can access the <code>java</code> command from the JRE. You probably have to set another variable called <code>PATH</code>. The <code>java</code> command may be called something different in your OS.</li>
<li>Run the <code>java</code> command with argument <code>math.plot.PlotterFrame</code> (<code>java math.plot.PlotterFrame</code>). If everything is okay, the main window of SSPlot will open.</li>
<li>Please see the last section on how to set up Jython or any other script engine if you are using a Java version > 14.</li>
</ol>

<h1>Documentation</h1>

<p>A manual is available inside the usr/share/doc/ssplot/manual directory.</p>
<p>A manual is available inside the <code>usr/share/doc/ssplot/manual</code> directory (or its link, the <code>doc</code> directory at the root) in pdf and odt formats. You can generate the pdf from the odt using LibreOffice Writer or any other tool you prefer.</p>

<h1>Compilation</h1>

<p>You will require Java JDK, Apache Ant and the Apache Commons Math library (version 3).</p>
<p>You will require Java JDK and Apache Ant. You will also require Markdown if you want to generate a html version of this Readme.</p>

<ol>
<li>Clone this repository.</li>
<li><code>cd</code> into the cloned directory and run <code>ant</code>. It will build everything and put the generated jar file into the jar directory.</li>
<li>You can run the generated <code>SSPlot.jar</code> file using the command <code>java -cp /usr/share/java/commons-math3.jar:jar/SSPlot.jar math.plot.PlotterFrame</code>, assuming the library is located in <code>/usr/share/java</code>. (Or using <code>./ssplot</code>)</li>
<li>You can run the generated <code>SSPlot.jar</code> file using the command <code>java -jar jar/SSPlot.jar</code> or just <code>./ssplot-quick-run</code></li>
</ol>

<h1>Manual Installation of Apache Math library</h1>
<h1>Using a external script engine for parsing math expressions</h1>

<p>If you decide to use the newer <code>SSPlot.jar</code> with experimental 3d support, you will need to install the Apache Commons Math library in your java CLASSPATH. As given in the <strong>Compilation</strong> section, if your Apache Commons Math library is installed in <code>/usr/share/java</code>, you can either run SSPlot with,</p>

<pre><code>java -cp /usr/share/java/commons-math3.jar:jar/SSPlot.jar math.plot.PlotterFrame
</code></pre>

<p>OR,</p>

<p>if your library is in <code>/usr/share/java</code> and <code>SSPlot.jar</code> is in your current directory, (for Linux only. Please search the internet on setting the java classpath if you are using any other OS.)</p>

<pre><code>export CLASSPATH="/usr/share/java:."
java math.plot.PlotterFrame
</code></pre>

<p>(Which is exactly what the <code>ssplot</code> script does.)</p>

<p>The main idea is that the math library and SSPlot.jar must be in your CLASSPATH before you can use <code>java math.plot.PlotterFrame</code> to launch the program.</p>

<p>Please adjust the <code>ssplot</code> script if anything is renamed or the Apache Commons Math library is installed in a different location.</p>

<h1>Installation with Java JRE >= 15</h1>

<p>Since the Nashorn Java engine is not available in Java versions > 14, so you will need to install a different JSR-223 compatible script engine in your Java CLASSPATH, in order for the dynamical system solver to work.</p>
<p>You can install a different JSR-223 compatible script engine in your Java CLASSPATH to use as an alternate Math expression parser.</p>

<p>A list of all available JSR-223 script engines can be found <a href="https://web.archive.org/web/20070610234337/https://scripting.dev.java.net/">here</a>.</p>

Expand Down
49 changes: 16 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,42 @@
A simple plotting utility for dynamical systems.

# Requirements
Any Java version less than 15. (and more than 6).
Any Java version >= 7.

# Installation
1. Install Java runtime (JRE). Version 14 preferred. Versions 15 and higher require some more work, which is explained in the last section. I use OpenJDK 14, which can be downloaded from [here](https://jdk.java.net/java-se-ri/14).
2. Download and install Apache Commons Math library (version 3) in your `CLASSPATH`. (Make sure it is installed in `/usr/share/java` for Linux, which is the case if it is installed by the package manager such as `apt`. You don't have to set the `CLASSPATH` for Linux. It is automatically done by the `ssplot` script.)
1. Install Java runtime (JRE).
3. Download the latest release of SSPlot from the releases section. (You can also clone this repository, either using `git clone` or using the Code menu in this page (Code -> Dropdown -> Download ZIP))
4. Extract the ZIP if you downloaded it.
4. Extract the ZIP.
5. Enter the folder inside the ZIP (or the cloned folder) and open a terminal there.
6. Run using `./ssplot` from your terminal/command line (For linux).
7. Alternatively, for other OSes, see the next section.
6. Run using `./ssplot-quick-run` from your terminal/command line (For linux), or go to the directory where the file `SSPlot.jar` is, open a terminal there and run `java -jar SSPlot.jar`
7. Alternatively, for other OSes, see the section __Other OSes__.
8. You may need to set the `CLASSPATH` environment variable if you want to use an alternate engine for math equation parsing, as explained in a later section.

# Short installation for Ubuntu
1. Install the dependencies. `sudo apt install openjdk-14-jre libcommons-math3-java`
2. Get the zip file from the Releases section and install the deb file from it `sudo dpkg -i ssplot-1.4.1.deb`
1. Install Java `sudo apt install default-jre`.
2. Get the zip file from the Releases section and install the deb file from it `sudo dpkg -i ssplot-1.5.deb`
3. You can now run SSPlot from the terminal by using the command `ssplot`.

# Other OSes.
Steps are same, except that,

1. You have to set the `CLASSPATH` yourself. You can search the internet for how to do that for your OS. Make sure that the `CLASSPATH` contains the Apache Commons Math library (version 3) and `SSPlot.jar`.
1. You may have to set the `CLASSPATH` yourself if you are using an external script engine. You can search the internet for how to do that for your OS. Make sure that the `CLASSPATH` contains the Apache Commons Math library (version 3) and `SSPlot.jar`. Not really needed as of version 1.5.
2. Make sure you can access the `java` command from the JRE. You probably have to set another variable called `PATH`. The `java` command may be called something different in your OS.
3. Run the `java` command with argument `math.plot.PlotterFrame` (`java math.plot.PlotterFrame`). If everything is okay, the main window of SSPlot will open.
4. Please see the last section on how to set up Jython or any other script engine if you are using a Java version > 14.
3. Please see the last section on how to set up Jython or any other script engine if you are using a Java version > 14.

# Documentation
A manual is available inside the usr/share/doc/ssplot/manual directory.
A manual is available inside the `usr/share/doc/ssplot/manual` directory (or its link, the `doc` directory at the root) in pdf and odt formats. You can generate the pdf from the odt using LibreOffice Writer or any other tool you prefer.

# Compilation
You will require Java JDK, Apache Ant and the Apache Commons Math library (version 3).
You will require Java JDK and Apache Ant. You will also require Markdown if you want to generate a html version of this Readme.

1. Clone this repository.
2. `cd` into the cloned directory and run `ant`. It will build everything and put the generated jar file into the jar directory.
3. You can run the generated `SSPlot.jar` file using the command `java -cp /usr/share/java/commons-math3.jar:jar/SSPlot.jar math.plot.PlotterFrame`, assuming the library is located in `/usr/share/java`. (Or using `./ssplot`)
3. You can run the generated `SSPlot.jar` file using the command `java -jar jar/SSPlot.jar` or just `./ssplot-quick-run`

# Manual Installation of Apache Math library
If you decide to use the newer `SSPlot.jar` with experimental 3d support, you will need to install the Apache Commons Math library in your java CLASSPATH. As given in the **Compilation** section, if your Apache Commons Math library is installed in `/usr/share/java`, you can either run SSPlot with,
# Using a external script engine for parsing math expressions

java -cp /usr/share/java/commons-math3.jar:jar/SSPlot.jar math.plot.PlotterFrame

OR,

if your library is in `/usr/share/java` and `SSPlot.jar` is in your current directory, (for Linux only. Please search the internet on setting the java classpath if you are using any other OS.)

export CLASSPATH="/usr/share/java:."
java math.plot.PlotterFrame

(Which is exactly what the `ssplot` script does.)

The main idea is that the math library and SSPlot.jar must be in your CLASSPATH before you can use `java math.plot.PlotterFrame` to launch the program.

Please adjust the `ssplot` script if anything is renamed or the Apache Commons Math library is installed in a different location.

# Installation with Java JRE >= 15
Since the Nashorn Java engine is not available in Java versions > 14, so you will need to install a different JSR-223 compatible script engine in your Java CLASSPATH, in order for the dynamical system solver to work.
You can install a different JSR-223 compatible script engine in your Java CLASSPATH to use as an alternate Math expression parser.

A list of all available JSR-223 script engines can be found [here](https://web.archive.org/web/20070610234337/https://scripting.dev.java.net/).

Expand Down
8 changes: 6 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<project name="SSPlot-Main" default="compile" basedir=".">

<target name="compile" description="Compile and create jars">
<!--<ant dir="src/math/prim" target="jar"/>-->
<mkdir dir="bin"/>
<ant dir="src/math/prim" target="compile"/>
<ant dir="src/parse" target="compile"/>
<ant dir="src/math/plot" target="jar"/>
</target>

<target name="clean" description="Cleaning up">
<!--<ant dir="src/math/prim" target="clean"/>-->
<ant dir="src/parse" target="clean"/>
<ant dir="src/math/prim" target="clean"/>
<ant dir="src/math/plot" target="clean"/>
</target>
</project>
1 change: 1 addition & 0 deletions doc
1 change: 1 addition & 0 deletions jar
40 changes: 19 additions & 21 deletions src/math/plot/PlotterFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,21 @@
package math.plot;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.geom.Point2D;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Vector;

import javax.imageio.ImageIO;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
Expand All @@ -49,7 +48,6 @@
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;
import javax.swing.JColorChooser;

@SuppressWarnings("serial")
public class PlotterFrame extends JFrame implements ActionListener {
Expand Down Expand Up @@ -177,22 +175,22 @@ public void mousePressed(MouseEvent ev) {

}
);
pv.addMouseWheelListener(
new MouseWheelListener() {
public void mouseWheelMoved(MouseWheelEvent ev) {
int x = ev.getX()-20;
int y = ev.getY()-20;

Point2D.Double p = pv.getCanvas().getInvTransformedPoint(new Point2D.Double(x, y));

if (ev.getWheelRotation() < 0) {
pv.zoomIn(p.getX(), p.getY());
} else if (ev.getWheelRotation() > 0) {
pv.zoomOut(p.getX(), p.getY());
}
}
}
);
// pv.addMouseWheelListener(
// new MouseWheelListener() {
// public void mouseWheelMoved(MouseWheelEvent ev) {
// int x = ev.getX()-20;
// int y = ev.getY()-20;
//
// Point2D.Double p = pv.getCanvas().getInvTransformedPoint(new Point2D.Double(x, y));
//
// if (ev.getWheelRotation() < 0) {
// pv.zoomIn(p.getX(), p.getY());
// } else if (ev.getWheelRotation() > 0) {
// pv.zoomOut(p.getX(), p.getY());
// }
// }
// }
// );

this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(pv, BorderLayout.CENTER);
Expand Down
62 changes: 49 additions & 13 deletions src/math/plot/Project2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

import java.awt.geom.Point2D;

import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import math.prim.Matrix;

public class Project2D {
double a, b, c;
Expand All @@ -43,19 +41,57 @@ public void setView(double a, double b, double c) {
this.c = c;
}

// public Point2D.Double project(double x, double y, double z) {
// Vector3D v = new Vector3D(x, y, z); /* Point to be projected */
//
// Rotation rot = new Rotation(new Vector3D(0,0,1), c, RotationConvention.VECTOR_OPERATOR);
// Rotation rot2 = new Rotation(new Vector3D(0,1,0), b, RotationConvention.VECTOR_OPERATOR);
// Rotation rot3 = new Rotation(new Vector3D(1,0,0), a, RotationConvention.VECTOR_OPERATOR);
//
// Vector3D camPos = new Vector3D(0, 0, 0); /* Position of the Camera */
// Vector3D camFrmPos = rot.applyTo(
// rot2.applyTo(
// rot3.applyTo(
// v.subtract(camPos))));
//
// return new Point2D.Double(camFrmPos.getX(), camFrmPos.getY());
// }

public Point2D.Double project(double x, double y, double z) {
Vector3D v = new Vector3D(x, y, z); /* Point to be projected */
Matrix rotX, rotY, rotZ, R, R2;
rotZ = new Matrix(3, 3);
rotY = new Matrix(3, 3);
rotX = new Matrix(3, 3);

R = new Matrix(3, 1);

R.set(x, 0, 0);
R.set(y, 1, 0);
R.set(z, 2, 0);

/* Rotation about Z */
rotZ.set(Math.cos(c), 0, 0);
rotZ.set(-Math.sin(c), 0, 1);
rotZ.set(Math.cos(c), 1, 1);
rotZ.set(Math.sin(c), 1, 0);
rotZ.set(1, 2, 2);

/* Rotation about Y */
rotY.set(Math.cos(b), 0, 0);
rotY.set(-Math.sin(b), 2, 0);
rotY.set(Math.cos(b), 2, 2);
rotY.set(Math.sin(b), 0, 2);
rotY.set(1, 1, 1);

Rotation rot = new Rotation(new Vector3D(0,0,1), c, RotationConvention.VECTOR_OPERATOR);
Rotation rot2 = new Rotation(new Vector3D(0,1,0), b, RotationConvention.VECTOR_OPERATOR);
Rotation rot3 = new Rotation(new Vector3D(1,0,0), a, RotationConvention.VECTOR_OPERATOR);
/* Rotation about X */
rotX.set(Math.cos(a), 1, 1);
rotX.set(-Math.sin(a), 1, 2);
rotX.set(Math.cos(a), 2, 2);
rotX.set(Math.sin(a), 2, 1);
rotX.set(1, 0, 0);

Vector3D camPos = new Vector3D(0, 0, 0); /* Position of the Camera */
Vector3D camFrmPos = rot.applyTo(
rot2.applyTo(
rot3.applyTo(
v.subtract(camPos))));
R2 = rotZ.times(rotY.times(rotX.times(R)));

return new Point2D.Double(camFrmPos.getX(), camFrmPos.getY());
return new Point2D.Double(R2.get(0, 0), R2.get(1, 0));
}
}
Loading

0 comments on commit 67eddf4

Please sign in to comment.