mirror of https://github.com/rusefi/jzy3d-api.git
implemented AxeTransformerSet
added the transformations to view
This commit is contained in:
parent
c2cd54a1f2
commit
05ddc19485
|
@ -6,6 +6,7 @@ import org.jzy3d.maths.BoundingBox3d;
|
||||||
import org.jzy3d.maths.Coord3d;
|
import org.jzy3d.maths.Coord3d;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformableAxes.AxeTransformableAxeBox;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformableAxes.AxeTransformableAxeBox;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
import org.jzy3d.plot3d.primitives.axes.AxeBox;
|
import org.jzy3d.plot3d.primitives.axes.AxeBox;
|
||||||
import org.jzy3d.plot3d.primitives.axes.IAxe;
|
import org.jzy3d.plot3d.primitives.axes.IAxe;
|
||||||
import org.jzy3d.plot3d.rendering.canvas.Quality;
|
import org.jzy3d.plot3d.rendering.canvas.Quality;
|
||||||
|
@ -13,47 +14,42 @@ import org.jzy3d.plot3d.rendering.view.View;
|
||||||
|
|
||||||
public class AxeTransformableAWTChartComponentFactory extends AWTChartComponentFactory{
|
public class AxeTransformableAWTChartComponentFactory extends AWTChartComponentFactory{
|
||||||
|
|
||||||
AxeTransformer transformerX;
|
AxeTransformerSet transformers;
|
||||||
AxeTransformer transformerY;
|
|
||||||
AxeTransformer transformerZ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AxeTransformableAWTChartComponentFactory(
|
public AxeTransformableAWTChartComponentFactory(
|
||||||
AxeTransformer transformerX, AxeTransformer transformerY,
|
AxeTransformerSet transformers) {
|
||||||
AxeTransformer transformerZ) {
|
this.transformers = transformers;
|
||||||
this.transformerX = transformerX;
|
|
||||||
this.transformerY = transformerY;
|
|
||||||
this.transformerZ = transformerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chart chart() {
|
public static Chart chart() {
|
||||||
return chart(Quality.Intermediate);
|
return chart(Quality.Intermediate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chart chart(Quality quality, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public static Chart chart(Quality quality, AxeTransformerSet transformers) {
|
||||||
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformerX, transformerY, transformerZ);
|
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformers);
|
||||||
return f.newChart(quality, Toolkit.newt);
|
return f.newChart(quality, Toolkit.newt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chart chart(String toolkit, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public static Chart chart(String toolkit, AxeTransformerSet transformers) {
|
||||||
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformerX, transformerY, transformerZ);
|
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformers);
|
||||||
return f.newChart(Chart.DEFAULT_QUALITY, toolkit);
|
return f.newChart(Chart.DEFAULT_QUALITY, toolkit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chart chart(Quality quality, Toolkit toolkit, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public static Chart chart(Quality quality, Toolkit toolkit, AxeTransformerSet transformers) {
|
||||||
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformerX, transformerY, transformerZ);
|
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformers);
|
||||||
return f.newChart(quality, toolkit);
|
return f.newChart(quality, toolkit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chart chart(Quality quality, String toolkit, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public static Chart chart(Quality quality, String toolkit, AxeTransformerSet transformers) {
|
||||||
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformerX, transformerY, transformerZ);
|
AxeTransformableAWTChartComponentFactory f = new AxeTransformableAWTChartComponentFactory(transformers);
|
||||||
return f.newChart(quality, toolkit);
|
return f.newChart(quality, toolkit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAxe newAxe(BoundingBox3d box, View view) {
|
public IAxe newAxe(BoundingBox3d box, View view) {
|
||||||
AxeTransformableAxeBox axe = new AxeTransformableAxeBox(box,transformerX,transformerY,transformerZ);
|
AxeTransformableAxeBox axe = new AxeTransformableAxeBox(box,transformers);
|
||||||
axe.setScale(new Coord3d(10.0,1.0,1.0));
|
axe.setScale(new Coord3d(10.0,1.0,1.0));
|
||||||
axe.setView(view);
|
axe.setView(view);
|
||||||
return axe;
|
return axe;
|
||||||
|
|
|
@ -9,16 +9,17 @@ import org.jzy3d.plot3d.builder.concrete.AxeTransformable.AxeTransformableOrthon
|
||||||
import org.jzy3d.plot3d.primitives.CompileableComposite;
|
import org.jzy3d.plot3d.primitives.CompileableComposite;
|
||||||
import org.jzy3d.plot3d.primitives.Shape;
|
import org.jzy3d.plot3d.primitives.Shape;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
|
|
||||||
public class axeTransformableBuilder extends Builder {
|
public class axeTransformableBuilder extends Builder {
|
||||||
|
|
||||||
public static Shape buildOrthonormal(OrthonormalGrid grid, Mapper mapper, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public static Shape buildOrthonormal(OrthonormalGrid grid, Mapper mapper, AxeTransformerSet transformers) {
|
||||||
AxeTransformableOrthonromalTassellator tesselator = new AxeTransformableOrthonromalTassellator(transformerX,transformerY,transformerZ);
|
AxeTransformableOrthonromalTassellator tesselator = new AxeTransformableOrthonromalTassellator(transformers);
|
||||||
return (Shape) tesselator.build(grid.apply(mapper));
|
return (Shape) tesselator.build(grid.apply(mapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompileableComposite buildOrthonormalBig(OrthonormalGrid grid, Mapper mapper, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public static CompileableComposite buildOrthonormalBig(OrthonormalGrid grid, Mapper mapper, AxeTransformerSet transformers) {
|
||||||
Tessellator tesselator = new AxeTransformableOrthonromalTassellator(transformerX,transformerY,transformerZ);
|
Tessellator tesselator = new AxeTransformableOrthonromalTassellator(transformers);
|
||||||
Shape s1 = (Shape) tesselator.build(grid.apply(mapper));
|
Shape s1 = (Shape) tesselator.build(grid.apply(mapper));
|
||||||
return buildComposite(applyStyling(s1));
|
return buildComposite(applyStyling(s1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,29 +5,25 @@ import org.jzy3d.plot3d.primitives.AbstractDrawable;
|
||||||
import org.jzy3d.plot3d.primitives.Point;
|
import org.jzy3d.plot3d.primitives.Point;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.AxeTransformablePolygon;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.AxeTransformablePolygon;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
|
|
||||||
public class AxeTransformableOrthonromalTassellator extends
|
public class AxeTransformableOrthonromalTassellator extends
|
||||||
OrthonormalTessellator {
|
OrthonormalTessellator {
|
||||||
|
|
||||||
AxeTransformer transformerX;
|
AxeTransformerSet transformers;
|
||||||
AxeTransformer transformerY;
|
|
||||||
AxeTransformer transformerZ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AxeTransformableOrthonromalTassellator(AxeTransformer transformerX,
|
public AxeTransformableOrthonromalTassellator(AxeTransformerSet transformers) {
|
||||||
AxeTransformer transformerY, AxeTransformer transformerZ) {
|
|
||||||
super();
|
super();
|
||||||
this.transformerX = transformerX;
|
this.transformers = transformers;
|
||||||
this.transformerY = transformerY;
|
|
||||||
this.transformerZ = transformerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractDrawable newQuad(Point p[]){
|
protected AbstractDrawable newQuad(Point p[]){
|
||||||
AxeTransformablePolygon quad = new AxeTransformablePolygon(transformerX,transformerY,transformerZ);
|
AxeTransformablePolygon quad = new AxeTransformablePolygon(transformers);
|
||||||
for(int pi=0; pi<p.length; pi++)
|
for(int pi=0; pi<p.length; pi++)
|
||||||
quad.add(p[pi]);
|
quad.add(p[pi]);
|
||||||
return quad;
|
return quad;
|
||||||
|
|
|
@ -5,30 +5,26 @@ import javax.media.opengl.GL;
|
||||||
import org.jzy3d.maths.Coord3d;
|
import org.jzy3d.maths.Coord3d;
|
||||||
import org.jzy3d.plot3d.primitives.AbstractGeometry;
|
import org.jzy3d.plot3d.primitives.AbstractGeometry;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
|
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
|
||||||
|
|
||||||
public abstract class AxeTransformableAbstractGeometry extends AbstractGeometry{
|
public abstract class AxeTransformableAbstractGeometry extends AbstractGeometry{
|
||||||
|
|
||||||
AxeTransformer transformerX;
|
AxeTransformerSet transformers;
|
||||||
AxeTransformer transformerY;
|
|
||||||
AxeTransformer transformerZ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AxeTransformableAbstractGeometry(AxeTransformer transformerX,
|
public AxeTransformableAbstractGeometry(AxeTransformerSet transformers) {
|
||||||
AxeTransformer transformerY, AxeTransformer transformerZ) {
|
|
||||||
super();
|
super();
|
||||||
this.transformerX = transformerX;
|
this.transformers = transformers;
|
||||||
this.transformerY = transformerY;
|
|
||||||
this.transformerZ = transformerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void vertexGL2(GL gl, Coord3d c) {
|
protected void vertexGL2(GL gl, Coord3d c) {
|
||||||
GlVertexExecutor.Vertex(gl, c, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c, transformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void vertexGL2(Coord3d c) {
|
protected void vertexGL2(Coord3d c) {
|
||||||
GLES2CompatUtils.glVertex3f(transformerX.compute(c.x), transformerY.compute(c.y),transformerZ.compute(c.z));
|
GLES2CompatUtils.glVertex3f(transformers.getX().compute(c.x), transformers.getY().compute(c.y),transformers.getZ().compute(c.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,15 @@ import javax.media.opengl.GL;
|
||||||
import javax.media.opengl.GL2;
|
import javax.media.opengl.GL2;
|
||||||
|
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
|
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
|
||||||
|
|
||||||
public class AxeTransformablePolygon extends AxeTransformableAbstractGeometry {
|
public class AxeTransformablePolygon extends AxeTransformableAbstractGeometry {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AxeTransformablePolygon(AxeTransformer trsX, AxeTransformer trsY , AxeTransformer trsZ) {
|
public AxeTransformablePolygon(AxeTransformerSet transformers) {
|
||||||
super(trsX,trsY,trsZ);
|
super(transformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void begin(GL gl) {
|
protected void begin(GL gl) {
|
||||||
|
|
|
@ -4,9 +4,10 @@ import javax.media.opengl.GL;
|
||||||
|
|
||||||
import org.jzy3d.maths.Coord3d;
|
import org.jzy3d.maths.Coord3d;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
|
|
||||||
public abstract class GlVertexExecutor {
|
public abstract class GlVertexExecutor {
|
||||||
public static void Vertex(GL gl, Coord3d c3d, AxeTransformer trsX, AxeTransformer trsY, AxeTransformer trsZ){
|
public static void Vertex(GL gl, Coord3d c3d,AxeTransformerSet transformers){
|
||||||
gl.getGL2().glVertex3d(trsX.compute(c3d.x), trsY.compute(c3d.y), trsZ.compute(c3d.z));
|
gl.getGL2().glVertex3d(transformers.getX().compute(c3d.x), transformers.getY().compute(c3d.y), transformers.getZ().compute(c3d.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.jzy3d.maths.BoundingBox3d;
|
||||||
import org.jzy3d.maths.Coord3d;
|
import org.jzy3d.maths.Coord3d;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.GlVertexExecutor;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.GlVertexExecutor;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
import org.jzy3d.plot3d.primitives.axes.AxeBox;
|
import org.jzy3d.plot3d.primitives.axes.AxeBox;
|
||||||
import org.jzy3d.plot3d.primitives.axes.layout.AxeBoxLayout;
|
import org.jzy3d.plot3d.primitives.axes.layout.AxeBoxLayout;
|
||||||
import org.jzy3d.plot3d.primitives.axes.layout.IAxeLayout;
|
import org.jzy3d.plot3d.primitives.axes.layout.IAxeLayout;
|
||||||
|
@ -23,15 +24,13 @@ import org.jzy3d.plot3d.text.align.Valign;
|
||||||
* @author Martin Pernollet
|
* @author Martin Pernollet
|
||||||
*/
|
*/
|
||||||
public class AxeTransformableAxeBox extends AxeBox {
|
public class AxeTransformableAxeBox extends AxeBox {
|
||||||
public AxeTransformableAxeBox(BoundingBox3d bbox,AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public AxeTransformableAxeBox(BoundingBox3d bbox,AxeTransformerSet transformers) {
|
||||||
this(bbox, new AxeBoxLayout(),transformerX, transformerY, transformerZ);
|
this(bbox, new AxeBoxLayout(),transformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxeTransformableAxeBox(BoundingBox3d bbox, IAxeLayout layout, AxeTransformer transformerX, AxeTransformer transformerY, AxeTransformer transformerZ) {
|
public AxeTransformableAxeBox(BoundingBox3d bbox, IAxeLayout layout, AxeTransformerSet transformers) {
|
||||||
super(bbox,layout);
|
super(bbox,layout);
|
||||||
this.transformerX = transformerX;
|
this.transformers = transformers;
|
||||||
this.transformerY = transformerY;
|
|
||||||
this.transformerZ = transformerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** reset to identity and apply scaling */
|
/** reset to identity and apply scaling */
|
||||||
|
@ -68,7 +67,7 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
//System.out.println(c3d.x);
|
//System.out.println(c3d.x);
|
||||||
//System.out.println(Math.log(c3d.x));
|
//System.out.println(Math.log(c3d.x));
|
||||||
|
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
}
|
}
|
||||||
gl.getGL2().glEnd();
|
gl.getGL2().glEnd();
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,7 +76,7 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
GLES2CompatUtils.glBegin(GL2.GL_QUADS);
|
GLES2CompatUtils.glBegin(GL2.GL_QUADS);
|
||||||
for (int v = 0; v < 4; v++) {
|
for (int v = 0; v < 4; v++) {
|
||||||
Coord3d c3d = new Coord3d(quadx[q][v], quady[q][v], quadz[q][v]);
|
Coord3d c3d = new Coord3d(quadx[q][v], quady[q][v], quadz[q][v]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
}
|
}
|
||||||
GLES2CompatUtils.glEnd();
|
GLES2CompatUtils.glEnd();
|
||||||
}
|
}
|
||||||
|
@ -96,9 +95,9 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
if (gl.isGL2()) {
|
if (gl.isGL2()) {
|
||||||
gl.getGL2().glBegin(GL2.GL_LINES);
|
gl.getGL2().glBegin(GL2.GL_LINES);
|
||||||
Coord3d c3d = new Coord3d(xticks[t], quady[quad][0], quadz[quad][0]);
|
Coord3d c3d = new Coord3d(xticks[t], quady[quad][0], quadz[quad][0]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
c3d = new Coord3d(xticks[t], quady[quad][2], quadz[quad][2]);
|
c3d = new Coord3d(xticks[t], quady[quad][2], quadz[quad][2]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
gl.getGL2().glEnd();
|
gl.getGL2().glEnd();
|
||||||
} else {
|
} else {
|
||||||
// FIXME TO BE REWRITTEN ANDROID
|
// FIXME TO BE REWRITTEN ANDROID
|
||||||
|
@ -112,9 +111,9 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
if (gl.isGL2()) {
|
if (gl.isGL2()) {
|
||||||
gl.getGL2().glBegin(GL2.GL_LINES);
|
gl.getGL2().glBegin(GL2.GL_LINES);
|
||||||
Coord3d c3d = new Coord3d(quadx[quad][0], yticks[t], quadz[quad][0]);
|
Coord3d c3d = new Coord3d(quadx[quad][0], yticks[t], quadz[quad][0]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
c3d = new Coord3d(quadx[quad][2], yticks[t], quadz[quad][2]);
|
c3d = new Coord3d(quadx[quad][2], yticks[t], quadz[quad][2]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
gl.getGL2().glEnd();
|
gl.getGL2().glEnd();
|
||||||
} else {
|
} else {
|
||||||
// FIXME TO BE REWRITTEN ANDROID
|
// FIXME TO BE REWRITTEN ANDROID
|
||||||
|
@ -128,9 +127,9 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
if (gl.isGL2()) {
|
if (gl.isGL2()) {
|
||||||
gl.getGL2().glBegin(GL2.GL_LINES);
|
gl.getGL2().glBegin(GL2.GL_LINES);
|
||||||
Coord3d c3d = new Coord3d(quadx[quad][0], quady[quad][0], zticks[t]);
|
Coord3d c3d = new Coord3d(quadx[quad][0], quady[quad][0], zticks[t]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
c3d = new Coord3d(quadx[quad][2], quady[quad][2], zticks[t]);
|
c3d = new Coord3d(quadx[quad][2], quady[quad][2], zticks[t]);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
gl.getGL2().glEnd();
|
gl.getGL2().glEnd();
|
||||||
} else {
|
} else {
|
||||||
// FIXME TO BE REWRITTEN ANDROID
|
// FIXME TO BE REWRITTEN ANDROID
|
||||||
|
@ -141,7 +140,7 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
|
|
||||||
public void drawAxisLabel(GL gl, GLU glu, Camera cam, int direction, Color color, BoundingBox3d ticksTxtBounds, double xlab, double ylab, double zlab, String axeLabel) {
|
public void drawAxisLabel(GL gl, GLU glu, Camera cam, int direction, Color color, BoundingBox3d ticksTxtBounds, double xlab, double ylab, double zlab, String axeLabel) {
|
||||||
if (isXDisplayed(direction) || isYDisplayed(direction) || isZDisplayed(direction)) {
|
if (isXDisplayed(direction) || isYDisplayed(direction) || isZDisplayed(direction)) {
|
||||||
Coord3d labelPosition = new Coord3d(transformerX.compute((float)xlab), transformerY.compute((float)ylab), transformerZ.compute((float)zlab));
|
Coord3d labelPosition = new Coord3d(transformers.getX().compute((float)xlab), transformers.getY().compute((float)ylab), transformers.getZ().compute((float)zlab));
|
||||||
BoundingBox3d labelBounds = txt.drawText(gl, glu, cam, axeLabel, labelPosition, Halign.CENTER, Valign.CENTER, color);
|
BoundingBox3d labelBounds = txt.drawText(gl, glu, cam, axeLabel, labelPosition, Halign.CENTER, Valign.CENTER, color);
|
||||||
if (labelBounds != null)
|
if (labelBounds != null)
|
||||||
ticksTxtBounds.add(labelBounds);
|
ticksTxtBounds.add(labelBounds);
|
||||||
|
@ -151,7 +150,7 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
public void drawAxisTickNumericLabel(GL gl, GLU glu, int direction, Camera cam, Color color, Halign hAlign, Valign vAlign, BoundingBox3d ticksTxtBounds, String tickLabel,
|
public void drawAxisTickNumericLabel(GL gl, GLU glu, int direction, Camera cam, Color color, Halign hAlign, Valign vAlign, BoundingBox3d ticksTxtBounds, String tickLabel,
|
||||||
Coord3d tickPosition) {
|
Coord3d tickPosition) {
|
||||||
//doTransform(gl);
|
//doTransform(gl);
|
||||||
tickPosition = new Coord3d(transformerX.compute(tickPosition.x), transformerY.compute(tickPosition.y), transformerZ.compute(tickPosition.z));
|
tickPosition = transformers.computePoint(tickPosition);
|
||||||
BoundingBox3d tickBounds = txt.drawText(gl, glu, cam, tickLabel, tickPosition, hAlign, vAlign, color);
|
BoundingBox3d tickBounds = txt.drawText(gl, glu, cam, tickLabel, tickPosition, hAlign, vAlign, color);
|
||||||
if (tickBounds != null)
|
if (tickBounds != null)
|
||||||
ticksTxtBounds.add(tickBounds);
|
ticksTxtBounds.add(tickBounds);
|
||||||
|
@ -164,13 +163,11 @@ public class AxeTransformableAxeBox extends AxeBox {
|
||||||
// Draw the tick line
|
// Draw the tick line
|
||||||
gl.getGL2().glBegin(GL2.GL_LINES);
|
gl.getGL2().glBegin(GL2.GL_LINES);
|
||||||
Coord3d c3d = new Coord3d(xpos, ypos, zpos);
|
Coord3d c3d = new Coord3d(xpos, ypos, zpos);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
c3d = new Coord3d(xlab, ylab, zlab);
|
c3d = new Coord3d(xlab, ylab, zlab);
|
||||||
GlVertexExecutor.Vertex(gl, c3d, transformerX, transformerY, transformerZ);
|
GlVertexExecutor.Vertex(gl, c3d, transformers);
|
||||||
gl.getGL2().glEnd();
|
gl.getGL2().glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AxeTransformer transformerX;
|
protected AxeTransformerSet transformers;
|
||||||
protected AxeTransformer transformerY;
|
|
||||||
protected AxeTransformer transformerZ;
|
|
||||||
}
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers;
|
||||||
|
|
||||||
|
import org.jzy3d.maths.Coord3d;
|
||||||
|
|
||||||
|
public class AxeTransformerSet {
|
||||||
|
private AxeTransformer x;
|
||||||
|
private AxeTransformer y;
|
||||||
|
private AxeTransformer z;
|
||||||
|
|
||||||
|
|
||||||
|
public AxeTransformerSet(AxeTransformer x, AxeTransformer y,
|
||||||
|
AxeTransformer z) {
|
||||||
|
super();
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxeTransformerSet() {
|
||||||
|
super();
|
||||||
|
this.x = new LinearAxeTransformer();
|
||||||
|
this.y = new LinearAxeTransformer();
|
||||||
|
this.z = new LinearAxeTransformer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxeTransformer getX() {
|
||||||
|
if(x != null)return x;
|
||||||
|
else return new LinearAxeTransformer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(AxeTransformer x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxeTransformer getY() {
|
||||||
|
if(y != null)return y;
|
||||||
|
else return new LinearAxeTransformer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(AxeTransformer y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxeTransformer getZ() {
|
||||||
|
if(z != null)return z;
|
||||||
|
else return new LinearAxeTransformer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(AxeTransformer z) {
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Coord3d computePoint(Coord3d point) {
|
||||||
|
return new Coord3d(getX().compute(point.x), getY().compute(point.y), getZ().compute(point.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers;
|
package org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers;
|
||||||
|
|
||||||
public class LinearTransformer implements AxeTransformer {
|
public class LinearAxeTransformer implements AxeTransformer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float compute(float value) {
|
public float compute(float value) {
|
|
@ -1,7 +1,7 @@
|
||||||
package org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers;
|
package org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers;
|
||||||
|
|
||||||
|
|
||||||
public class LogTransformer implements AxeTransformer{
|
public class LogAxeTransformer implements AxeTransformer{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float compute(float value) {
|
public float compute(float value) {
|
|
@ -22,6 +22,7 @@ import org.jzy3d.maths.BoundingBox3d;
|
||||||
import org.jzy3d.maths.Coord2d;
|
import org.jzy3d.maths.Coord2d;
|
||||||
import org.jzy3d.maths.Coord3d;
|
import org.jzy3d.maths.Coord3d;
|
||||||
import org.jzy3d.maths.Rectangle;
|
import org.jzy3d.maths.Rectangle;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
import org.jzy3d.plot3d.primitives.axes.AxeBox;
|
import org.jzy3d.plot3d.primitives.axes.AxeBox;
|
||||||
import org.jzy3d.plot3d.primitives.axes.IAxe;
|
import org.jzy3d.plot3d.primitives.axes.IAxe;
|
||||||
import org.jzy3d.plot3d.rendering.canvas.ICanvas;
|
import org.jzy3d.plot3d.rendering.canvas.ICanvas;
|
||||||
|
@ -96,6 +97,7 @@ public class View {
|
||||||
this.scene.getGraph().getStrategy().setView(this);
|
this.scene.getGraph().getStrategy().setView(this);
|
||||||
|
|
||||||
current = this;
|
current = this;
|
||||||
|
transformers = new AxeTransformerSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chart getChart() {
|
public Chart getChart() {
|
||||||
|
@ -595,9 +597,9 @@ public class View {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute factors
|
// Compute factors
|
||||||
float xLen = (float) (Math.log(bounds.getXmax()) - Math.log(bounds.getXmin())); //------------------------apply the transformers to this calculations
|
float xLen = transformers.getX().compute(bounds.getXmax()) - transformers.getX().compute(bounds.getXmin());
|
||||||
float yLen = bounds.getYmax() - bounds.getYmin();
|
float yLen = transformers.getY().compute(bounds.getYmax()) - transformers.getY().compute(bounds.getYmin());
|
||||||
float zLen = bounds.getZmax() - bounds.getZmin();
|
float zLen = transformers.getZ().compute(bounds.getZmax()) - transformers.getZ().compute(bounds.getZmin());
|
||||||
float lmax = (float) Math.max(Math.max(xLen, yLen), zLen);
|
float lmax = (float) Math.max(Math.max(xLen, yLen), zLen);
|
||||||
|
|
||||||
if (Float.isInfinite(xLen) || Float.isNaN(xLen) || xLen == 0)
|
if (Float.isInfinite(xLen) || Float.isNaN(xLen) || xLen == 0)
|
||||||
|
@ -841,8 +843,8 @@ public class View {
|
||||||
public void updateCamera(GL gl, GLU glu, ViewportConfiguration viewport,
|
public void updateCamera(GL gl, GLU glu, ViewportConfiguration viewport,
|
||||||
BoundingBox3d boundsScaled) {
|
BoundingBox3d boundsScaled) {
|
||||||
Coord3d center = boundsScaled.getCenter();
|
Coord3d center = boundsScaled.getCenter();
|
||||||
center = new Coord3d(Math.log(center.x), center.y, center.z); //-------------------------------------------------apply the transformer both to the center and to the bounds and then calculate the radius(maybe implement the transformableRadius in the BoundingBox3d)
|
center = transformers.computePoint(center); //(maybe implement the transformableRadius in the BoundingBox3d)
|
||||||
float radius = (float) center.distance(new Coord3d(Math.log(boundsScaled.getXmin()), boundsScaled.getYmin(), boundsScaled.getZmin()));
|
float radius = (float) center.distance(transformers.computePoint(new Coord3d(boundsScaled.getXmin(), boundsScaled.getYmin(), boundsScaled.getZmin())));
|
||||||
updateCamera(gl, glu, viewport, boundsScaled,
|
updateCamera(gl, glu, viewport, boundsScaled,
|
||||||
/*(float) boundsScaled.getRadius()*/
|
/*(float) boundsScaled.getRadius()*/
|
||||||
radius);
|
radius);
|
||||||
|
@ -850,10 +852,9 @@ public class View {
|
||||||
|
|
||||||
public void updateCamera(GL gl, GLU glu, ViewportConfiguration viewport,
|
public void updateCamera(GL gl, GLU glu, ViewportConfiguration viewport,
|
||||||
BoundingBox3d boundsScaled, float sceneRadiusScaled) {
|
BoundingBox3d boundsScaled, float sceneRadiusScaled) {
|
||||||
//Coord3d scaling2 = new Coord3d(Math.log(scaling.x), scaling.y, scaling.z);
|
|
||||||
Coord3d target = center.mul(scaling);
|
Coord3d target = center.mul(scaling);
|
||||||
target = new Coord3d(Math.log(target.x), target.y, target.z); //-----------------------------------------------apply transformation to target
|
target = transformers.computePoint(target);
|
||||||
|
//target = new Coord3d(transformers.getX().compute(target.x), transformers.getY().compute(target.y), target.z);
|
||||||
Coord3d eye;
|
Coord3d eye;
|
||||||
viewpoint.z = sceneRadiusScaled * factorViewPointDistance;
|
viewpoint.z = sceneRadiusScaled * factorViewPointDistance;
|
||||||
if (viewmode == ViewPositionMode.FREE) {
|
if (viewmode == ViewPositionMode.FREE) {
|
||||||
|
@ -885,6 +886,7 @@ public class View {
|
||||||
wasOnTopAtLastRendering = true;
|
wasOnTopAtLastRendering = true;
|
||||||
fireViewOnTopEvent(true);
|
fireViewOnTopEvent(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// handle up vector
|
// handle up vector
|
||||||
up = new Coord3d(0, 0, 1);
|
up = new Coord3d(0, 0, 1);
|
||||||
|
@ -895,7 +897,6 @@ public class View {
|
||||||
fireViewOnTopEvent(false);
|
fireViewOnTopEvent(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Apply camera settings ------------------------
|
// -- Apply camera settings ------------------------
|
||||||
cam.setTarget(target);
|
cam.setTarget(target);
|
||||||
cam.setUp(up);
|
cam.setUp(up);
|
||||||
|
@ -976,8 +977,20 @@ public class View {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
public AxeTransformerSet getTransformers() {
|
||||||
|
return transformers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransformers(AxeTransformerSet transformers) {
|
||||||
|
this.transformers = transformers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** A view may optionnaly know its parent chart. */
|
/** A view may optionnaly know its parent chart. */
|
||||||
protected Chart chart;
|
protected Chart chart;
|
||||||
|
|
||||||
|
@ -1052,5 +1065,6 @@ public class View {
|
||||||
/** A slave view won't clear its color and depth buffer before rendering */
|
/** A slave view won't clear its color and depth buffer before rendering */
|
||||||
protected boolean slave = false;
|
protected boolean slave = false;
|
||||||
|
|
||||||
|
protected AxeTransformerSet transformers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,11 @@ import org.jzy3d.plot3d.builder.Builder;
|
||||||
import org.jzy3d.plot3d.builder.Mapper;
|
import org.jzy3d.plot3d.builder.Mapper;
|
||||||
import org.jzy3d.plot3d.builder.axeTransformable.axeTransformableBuilder;
|
import org.jzy3d.plot3d.builder.axeTransformable.axeTransformableBuilder;
|
||||||
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
|
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
|
||||||
|
import org.jzy3d.plot3d.primitives.CompileableComposite;
|
||||||
import org.jzy3d.plot3d.primitives.Shape;
|
import org.jzy3d.plot3d.primitives.Shape;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.LinearTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
|
||||||
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.LogTransformer;
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.LinearAxeTransformer;
|
||||||
|
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.LogAxeTransformer;
|
||||||
import org.jzy3d.plot3d.rendering.canvas.Quality;
|
import org.jzy3d.plot3d.rendering.canvas.Quality;
|
||||||
import org.jzy3d.plot3d.rendering.view.*;
|
import org.jzy3d.plot3d.rendering.view.*;
|
||||||
import org.jzy3d.plot3d.rendering.view.modes.ViewPositionMode;
|
import org.jzy3d.plot3d.rendering.view.modes.ViewPositionMode;
|
||||||
|
@ -26,26 +28,29 @@ public class LogTest {
|
||||||
// Define a function to plot
|
// Define a function to plot
|
||||||
Mapper mapper = new Mapper() {
|
Mapper mapper = new Mapper() {
|
||||||
public double f(double x, double y) {
|
public double f(double x, double y) {
|
||||||
//return (10 * Math.sin(x) * Math.cos(y) * x) / 1000;
|
double value = Math.abs((10 * Math.sin(x) * Math.cos(y) * x) / 10) + 10;
|
||||||
return x+y/2;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define range and precision for the function to plot
|
// Define range and precision for the function to plot
|
||||||
Range range = new Range((float)0.1, 100);
|
Range range = new Range((float)0.1, 1000);
|
||||||
Range range2 = new Range((float)0.1,10);
|
Range range2 = new Range((float)0.1,50);
|
||||||
int steps = 50;
|
int steps = 200;
|
||||||
|
|
||||||
|
AxeTransformerSet transformers = new AxeTransformerSet(new LinearAxeTransformer(), new LogAxeTransformer(), new LinearAxeTransformer());
|
||||||
|
|
||||||
// Create a surface drawing that function
|
// Create a surface drawing that function
|
||||||
Shape surface = axeTransformableBuilder.buildOrthonormal(new OrthonormalGrid(range, steps, range2, steps), mapper, new LogTransformer(), new LinearTransformer(), new LinearTransformer());
|
CompileableComposite surface = axeTransformableBuilder.buildOrthonormalBig(new OrthonormalGrid(range, steps, range2, steps), mapper, transformers);
|
||||||
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
|
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
|
||||||
surface.setFaceDisplayed(true);
|
surface.setFaceDisplayed(true);
|
||||||
surface.setWireframeDisplayed(false);
|
surface.setWireframeDisplayed(false);
|
||||||
surface.setWireframeColor(Color.BLACK);
|
surface.setWireframeColor(Color.BLACK);
|
||||||
|
|
||||||
// Create a chart and add the surface
|
// Create a chart and add the surface
|
||||||
Chart chart = AxeTransformableAWTChartComponentFactory.chart(Quality.Advanced, new LogTransformer(), new LinearTransformer(), new LinearTransformer());
|
Chart chart = AxeTransformableAWTChartComponentFactory.chart(Quality.Advanced, transformers);
|
||||||
chart.getScene().getGraph().add(surface);
|
chart.getScene().getGraph().add(surface);
|
||||||
|
chart.getView().setTransformers(transformers);
|
||||||
ChartLauncher.openChart(chart);
|
ChartLauncher.openChart(chart);
|
||||||
/*Shape surface = Builder.buildOrthonormal(new OrthonormalGrid(range, steps, range2, steps), mapper);
|
/*Shape surface = Builder.buildOrthonormal(new OrthonormalGrid(range, steps, range2, steps), mapper);
|
||||||
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
|
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
|
||||||
|
|
Loading…
Reference in New Issue