mirror of https://github.com/rusefi/jzy3d-api.git
rename non test code for maven, slight coord2d improvements
This commit is contained in:
parent
f823819b32
commit
25bdc9bf18
|
@ -17,13 +17,20 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class SimpleFile {
|
||||
public static void write(String content, String file) throws IOException {
|
||||
public static void write(String content, String file) throws Exception {
|
||||
createParentFoldersIfNotExist(file);
|
||||
Writer out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
|
||||
out.write(content);
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void createParentFoldersIfNotExist(String file) {
|
||||
File parent = (new File(file)).getParentFile();
|
||||
if (parent != null && !parent.exists())
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
|
||||
public static List<String> read(String filename) throws IOException {
|
||||
List<String> output = new ArrayList<String>();
|
||||
File file = new File(filename);
|
||||
|
@ -35,6 +42,7 @@ public class SimpleFile {
|
|||
output.add(dis.readLine());
|
||||
}
|
||||
|
||||
|
||||
fis.close();
|
||||
bis.close();
|
||||
dis.close();
|
||||
|
@ -54,7 +62,6 @@ public class SimpleFile {
|
|||
while (dis.available() != 0) {
|
||||
sb.append((new StringBuilder()).append(dis.readLine()).append(newLineString));
|
||||
}
|
||||
|
||||
fis.close();
|
||||
bis.close();
|
||||
dis.close();
|
||||
|
@ -76,11 +83,4 @@ public class SimpleFile {
|
|||
else
|
||||
return f1.lastModified() > f2.lastModified();
|
||||
}
|
||||
|
||||
public static void createParentFoldersIfNotExist(String file) {
|
||||
File parent = (new File(file)).getParentFile();
|
||||
if (parent != null && !parent.exists())
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,9 +39,17 @@ public class Coord2d {
|
|||
public Coord2d clone(){
|
||||
return new Coord2d(x,y);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
|
||||
public void set(Coord2d c){
|
||||
this.x = c.x;
|
||||
this.y = c.y;
|
||||
}
|
||||
|
||||
public void set(float x, float y){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/** Add a Coord2d to the current one and return the result
|
||||
* in a new Coord2d.
|
||||
* @param c2
|
||||
|
@ -61,6 +69,14 @@ public class Coord2d {
|
|||
this.y+=y;
|
||||
}
|
||||
|
||||
public void addSelfX(float x){
|
||||
this.x+=x;
|
||||
}
|
||||
|
||||
public void addSelfY(float y){
|
||||
this.y+=y;
|
||||
}
|
||||
|
||||
/** Add a value to all components of the current Coord and return the result
|
||||
* in a new Coord2d.
|
||||
* @param value
|
||||
|
@ -194,7 +210,25 @@ public class Coord2d {
|
|||
public double distance(Coord2d c){
|
||||
return Math.sqrt( Math.pow(x-c.x,2) + Math.pow(y-c.y,2) );
|
||||
}
|
||||
|
||||
public double distanceSq(Coord2d c){
|
||||
return Math.pow(x-c.x,2) + Math.pow(y-c.y,2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an interpolated point between the current and given point,
|
||||
* according to an input ratio in [0;1] that indicates how near to the
|
||||
* current point the new point will stand.
|
||||
*
|
||||
* A value of 1 will return a copy of the current point.
|
||||
*/
|
||||
public Coord2d interpolation(Coord2d c, float ratio){
|
||||
float inv = 1-ratio;
|
||||
float xx = x*ratio+c.x*inv;
|
||||
float yy = y*ratio+c.y*inv;
|
||||
return new Coord2d(xx,yy);
|
||||
}
|
||||
|
||||
/** Return a string representation of this coordinate.*/
|
||||
public String toString(){
|
||||
return ("x=" + x + " y=" + y);
|
||||
|
|
|
@ -804,11 +804,7 @@ public class View {
|
|||
}
|
||||
|
||||
public BoundingBox3d computeScaling() {
|
||||
// -- Scale the scene's view -------------------
|
||||
if (squared) // force square scale
|
||||
scaling = squarify();
|
||||
else
|
||||
scaling = Coord3d.IDENTITY.clone();
|
||||
scaling = computeSceneScaling();
|
||||
|
||||
// -- Compute the bounds for computing cam distance, clipping planes,
|
||||
// etc
|
||||
|
@ -823,6 +819,14 @@ public class View {
|
|||
return boundsScaled;
|
||||
}
|
||||
|
||||
public Coord3d computeSceneScaling() {
|
||||
// -- Scale the scene's view -------------------
|
||||
if (squared) // force square scale
|
||||
return squarify();
|
||||
else
|
||||
return Coord3d.IDENTITY.clone();
|
||||
}
|
||||
|
||||
public void updateCamera(GL gl, GLU glu, ViewportConfiguration viewport,
|
||||
BoundingBox3d boundsScaled) {
|
||||
updateCamera(gl, glu, viewport, boundsScaled,
|
||||
|
|
|
@ -48,11 +48,11 @@ import org.jzy3d.plot3d.text.drawable.DrawableTextBillboard;
|
|||
*
|
||||
* @author Martin
|
||||
*/
|
||||
public class TestFaceOrdering1 {
|
||||
public class PseudoTestFaceOrdering1 {
|
||||
static double MAPPER_ZSCALE_FACTOR = 100;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TestFaceOrdering1 surface = new TestFaceOrdering1();
|
||||
PseudoTestFaceOrdering1 surface = new PseudoTestFaceOrdering1();
|
||||
surface.BuildAndLaunch();
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ public class TestFaceOrdering1 {
|
|||
/**
|
||||
* Surface
|
||||
*/
|
||||
public TestFaceOrdering1() {
|
||||
public PseudoTestFaceOrdering1() {
|
||||
_expX = new double[] { -1.0, 1.0, 0.0, 0.0, 0.0 };
|
||||
_expY = new double[] { 0.0, 0.0, -1.0, 1.0, 0.0 };
|
||||
_expZ = new double[] { 1799635.862225038, 2778958.3605334656, 2308941.6737486282, 2791418.430038142, 2778052.031336538 };
|
|
@ -19,9 +19,9 @@ import org.jzy3d.plot3d.primitives.Shape;
|
|||
import org.jzy3d.plot3d.rendering.canvas.Quality;
|
||||
import org.jzy3d.plot3d.rendering.view.modes.ViewBoundMode;
|
||||
|
||||
public class TestManualBounds extends AbstractAnalysis {
|
||||
public class PseudoTestManualBounds extends AbstractAnalysis {
|
||||
public static void main(String[] args) throws Exception {
|
||||
IAnalysis d = new TestManualBounds();
|
||||
IAnalysis d = new PseudoTestManualBounds();
|
||||
d.setCanvasType("newt");
|
||||
AnalysisLauncher.open(d);
|
||||
|
Loading…
Reference in New Issue