For details, see How to Use.
Plotting a File on a 3D Graph (Point/Line Graph)
This VCSSL program plots the contents of a file containing coordinate values on a 3D graph. It's a short sample code thatfs ideal for modification or reuse.
When executed, it first writes sample coordinate values to a file named "sample3d.txt", and then plots them on a 3D graph.
» Related page: 3D Graph Plotting in Java
Sponsored Link
How to Use
Download and Extract
At first, click the "Download" button at the above of the title of this page by your PC (not smartphone). A ZIP file will be downloaded.
Then, please extract the ZIP file. On general environment (Windows®, major Linux distributions, etc.), you can extract the ZIP file by selecting "Extract All" and so on from right-clicking menu.
» If the extraction of the downloaded ZIP file is stopped with security warning messages...
Execute this Program
Next, open the extracted folder and execute this VCSSL program.
For Windows
Double-click the following batch file to execute:
For Linux, etc.
Execute "VCSSL.jar" on the command-line terminal as follows:
java -jar VCSSL.jar
» If the error message about non-availability of "java" command is output...
After Launching
Upon launching, the program writes out a file with sample coordinate values (sample3d.txt), then starts the 3D graph software, which plots the file contents.
To change the plotted data, edit the part of the code that generates the coordinate values (inside the for loop).
Code Explanation
Letfs take a look at the code used in this program. The code is written in VCSSL.
Full Code
First, here's the full code. Itfs very short, around 20 lines:
That's all. The first half writes out the coordinate file, and the second half plots it on the graph.
First Part
Let's take a closer look at the first part:
The line "coding UTF-8;" specifies the character encoding of the program. It's not required, but including it helps prevent character corruption issues.
The line import tool.Graph3D; loads the tool.Graph3D library, which is needed to work with 3D graphs.
Writing Sample Coordinate File
Next is the part where the sample coordinate data is written to a file:
This code writes the coordinates in the following format:
x1 y1 z1
x2 y2 z2
c
Each line represents one point (x, y, z), with values separated by tabs. The file is named "sample3d.txt", and its contents look like this:
1.0 1.0 2.0
2.0 4.0 6.0
3.0 9.0 12.0
4.0 16.0 20.0
5.0 25.0 30.0
6.0 36.0 42.0
7.0 49.0 56.0
8.0 64.0 72.0
9.0 81.0 90.0
10.0 100.0 110.0
This corresponds to the functions "y = x * x" and "z = x + y", with x ranging from 0 to 10.
This format is commonly used and widely supported by many graphing tools. In the standard VCSSL environment, the 3D graph plotting feature uses RINEARN Graph 3D, which also supports this format.
Plotting
Finally, herefs the part that plots the file on a 3D graph:
The newGraph3D() function launches the 3D graph software. Each time it is called, a new instance of the software starts and returns a unique ID number.
For example, if you start multiple graph windows, they might be assigned IDs like Graph #12, #22, #101, and so on. In this case, the returned ID is stored in the int variable "graph".
Next, the setGraph3DFile() function is used to plot the file "sample3d.txt" in the newly launched 3D graph. The first argument specifies the ID of the graph instance to control, using the graph variable. Even if you have multiple graphs open, you can control each one individually by specifying its ID.
License
The license of this VCSSL / Vnano code (the file with the extension ".vcssl" / ".vnano") is CC0 (Public Domain), so you can customize / divert / redistribute this VCSSL code freely.
Also, if example code written in C/C++/Java are displayed/distributed on Code section of this page, they also are distributed under CC0, unless otherwise noted.
3D Graph Plotting Tool for Animating Data Loaded from Multiple Files |
|
![]() |
A simple tool which plots 3D animation graphs by loading multiple data files. |
2D Graph Plotting Tool for Animating Data Loaded from Multiple Files |
|
![]() |
A simple tool which plots 2D animation graphs by loading multiple data files. |
3D Graph Tool for Plotting & Animating Expressions of the Form of "z = f(x,y,t)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "z = f(x,y,t)" to the 3D graph, and plays it as animation. |
2D Graph Tool for Plotting & Animating Expressions of the Form of "y = f(x,t)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "y = f(x,t)" to the 2D graph, and plays it as animation. |
3D Graph Tool for Plotting & Animating Parametric Expressions of the Form of x(t), y(t), z(t) |
|
![]() |
A simple tool which plots parametric expressions (formulas) of the form of x(t), y(t), z(t) to the 3D graph, and plays it as animation. |
2D Graph Tool for Plotting & Animating Parametric Expressions of the Form of x(t) and y(t) |
|
![]() |
A simple tool which plots parametric expressions (formulas) of the form of x(t) and y(t) to the 2D graph, and plays it as animation. |
3D Graph Tool for Plotting Expressions of the Form of "z = f(x,y)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "z = f(x,y)" to the 3D graph. |
2D Graph Tool for Plotting Expressions of the Form of "y = f(x)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "y = f(x)" to the 2D graph. |
Animating a 3D Graph by Continuously Plotting Arrays (Surface/Mesh Plot) |
|
![]() |
Explains how to create 3D surface/mesh graph animations by updating arrays over time. |
Animating a 3D Graph by Continuously Plotting Arrays (Point/Line Plot) |
|
![]() |
Explains how to create 3D point/line graph animations by updating arrays over time. |
Animating a 2D Graph by Continuously Plotting Arrays |
|
![]() |
Explains how to create 2D graph animations by updating arrays over time. |
Plotting Arrays on a 3D Graph (Surface/Mesh Plot) |
|
![]() |
Explains how to plot coordinate data stored in an array on a 3D surface/mesh graph with sample code. |
Plotting a File on a 3D Graph (Surface/Mesh Plot) |
|
![]() |
Explains how to plot coordinate data from a file on a 3D surface/mesh graph with sample code. |
Plotting Arrays on a 3D Graph (Point/Line Graph) |
|
![]() |
Explains how to plot coordinate data stored in an array on a 3D graph with sample code. |
Plotting Arrays on a 2D Graph |
|
![]() |
Explains how to plot coordinate data stored in an array on a 2D graph with sample code. |
Plotting a File on a 3D Graph (Point/Line Graph) |
|
![]() |
Explains how to plot coordinate data from a file on a 3D graph with sample code. |
Plotting a File on a 2D Graph |
|
![]() |
Explains how to plot coordinate data from a file on a 2D graph with sample code. |