Axis scaling is overridden in IDL - idl-programming-language

The scaling for axes X,Y and Z that I specify in the procedure scale3 is overridden. I don't understand why? Could someone point out what is wrong with my code?
The width of a box is n1/2-1(~128 points) and it is more than the height(98 points).
n1=257
n2=257
n3=98
file='test.ps'
set_plot,'Z'
erase,255
scale3,XRange=[0,n1-1],YRange=[0,n2-1],ZRange=[0,n3-1],az=-30,ax=30
PLOTS,[0,n1-1],[0,0],[0,0],/T3D,color=0,thick=2
PLOTS,[0,0],[0,n2-1],[0,0],/T3D,color=0,thick=2
PLOTS,[0,n1-1],[n2-1,n2-1],[0,0],/T3D,color=0,thick=2
PLOTS,[n1-1,n1-1],[0,n2-1],[0,0],/T3D,color=0,thick=2
PLOTS,[0,n1-1],[n2-1,n2-1],[n3-1,n3-1],/T3D,color=0,thick=2
PLOTS,[n1-1,n1-1],[0,n2-1],[n3-1,n3-1],/T3D,color=0,thick=2
PLOTS,[0,n1-1],[0,0],[n3-1,n3-1],/T3D,color=0,thick=2
PLOTS,[0,0],[0,n2-1],[n3-1,n3-1],/T3D,color=0,thick=2
PLOTS,[0,0],[0,0],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[n1/2-1,n1/2-1],[0,0],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[n1-1,n1-1],[0,0],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[n1-1,n1-1],[n2-1,n2-1],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[0,0],[n2-1,n2-1],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[n1/2-1,n1/2-1],[0,n2-1],[n3-1,n3-1],/T3D,color=0,thick=2
PLOTS,[0,n1-1],[n2/2-1,n2/2-1],[n3-1,n3-1],/T3D,color=0,thick=2
PLOTS,[n1-1,n1-1],[n2/2-1,n2/2-1],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[n1/2-1,n1/2-1],[0,n2-1],[0,0],/T3D,color=0,thick=2
PLOTS,[0,0],[n2/2-1,n2/2-1],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[n1/2-1,n1/2-1],[n2-1,n2-1],[0,n3-1],/T3D,color=0,thick=2
PLOTS,[0,n1-1],[n2/2-1,n2/2-1],[0,0],/T3D,color=0,thick=2
g=TVRD()
set_plot,'PS'
device,filename=file,xsize=8,ysize=6,/encapsulated
tv,g
device,/close
end

Do you mean mean the display is anisotropic? Just add:
device, set_resolution=[500, 500]
after you change to the Z-buffer device. This is what I get:

Related

Plotting a simple flower

I need to make ellipses go around a circle to make a flower, i've gotten pretty close to the solution but I don't know how to fix it, it's going through the circle, is there any way I could make the ellipes shorter + go around the circle?
This is the code:
pkg load geometry
clf
figure;
t=0:0.01:2*pi;
x=10*cos(t);
y=3*sin(t)/2;
for i=1:12
hold on;
q=[x;y];
e=pi/12*i;
z=[cos(e) -sin(e);sin(e) cos(e)];
k=z*q;
r=k(1,:);
d=k(2,:);
plot(r,d);
axis square;
pause(1);
endfor
hold on;
drawCircle(0,0,1);
This is what mine looks like:
This is what it is supposed to look like:
You need to circle the ellipses' centres as well, they're all centred on the origin now. That means, add a static offset. Something like
dist = 1; % Distance from the origin, change as necessary
x_Offset = dist * cos(e);
y_Offset = dist * sin(e);
plot(r + x_Offset, d + y_Offset);

Guaranteeing that node is above all other nodes in group

I am currently trying to make a group of arcs, with text above them. This seems to be working, but for only half the cases. The other half is ending up below the arc node and is invisible.
I have tried using node.tofront() , toback() etc but it is still not changing anything.
class pieslice extends Group{
pieslice(double centerx,double centery,double segpart,double totalseg){
Text value= new Text(String.format("%.2f",worth));
segment = totalseg;
Arc innerArc=new Arc();
Arc outerArc=new Arc();
outerArc.setType(ArcType.ROUND);
innerArc.setType(ArcType.ROUND);
value.setFill(Color.WHITE);
innerArc.setStrokeWidth(1);
innerArc.setRadiusX(150.0f);
innerArc.setRadiusY(150.0f);
outerArc.setRadiusX(innerArc.getRadiusX()+10);
outerArc.setRadiusY(innerArc.getRadiusY()+10);
outerArc.setFill(Color.WHITE);
innerArc.setStartAngle((360/segment)*segpart);
outerArc.setStartAngle((360/segment)*segpart);
innerArc.setCenterX(centerx);
innerArc.setCenterY(centery);
outerArc.setCenterX(centerx);
outerArc.setCenterX(centery);
innerArc.setLength(360/segment);
outerArc.setLength(360/segment);
innerArc.setStrokeWidth(1);
innerArc.setStroke(Color.BLACK);
innerArc.setFill(Color.color(Math.random(),Math.random(),Math.random()));
value.setX(150);
value.setFill(Color.BLACK);
value.getTransforms().add(new Rotate((360/segment)*segpart+((360/segment)/2),0,0));
System.out.println((360/segment)*segpart+((360/segment)/2));
this.getChildren().add(outerArc);
this.getChildren().get(0).setViewOrder(2);
this.getChildren().add(innerArc);
this.getChildren().add(value);}
I would expect that since I am adding the two arcs (Inner and outer for aesthetic effect only) and then the text, that the text would be rendered above the shapes, but that is not the case. Any ideas?

Matlab 3D Plot with constraint

i want to plot something like this:
3*x*y
with a constraint
x^2+y^2=8
in Matlab, so it should look like this:
http://www.wolframalpha.com/input/?i=maximize+3xy+on+x%C2%B2%2By%C2%B2%3D8
any ideas?
i tryed
ezsurf(#(x,y)3*x.*y)
hold
fimplicit(#(x,y)x.^2+y.^2-8)
but the result is bad, the line plot doesn't follow the surface
i did it!
a=#(x,y)3*x.*y
b=#(x,y)x.^2+y.^2-8
constpl(a,b)
and constpl is my own defined function
function constpl(fun,constraint)
a=fimplicit(constraint);
x=a.XData;
y=a.YData;
z=fun(x,y);
ind=z>=max(z)-0.000001;
x1=x(ind);
y1=y(ind);
z1=z(ind);
ezmesh(fun);
hold on
plot3(x,y,z,'r','LineWidth',2)
scatter3(x1,y1,z1,'rd','LineWidth',3)
hold off
end

How to make a very large skybox? (babylon.js)

How can I make a very large skybox?
Example:
var skybox = BABYLON.Mesh.CreateBox("skyBox", 15000.0, this.scene);
The result is bad:
The first thing I suggest is to reduce the scale factor of your spaceship and planet models. It seems that having a SkyBox size larger than 10000 causes the ugly texture seams/tearing of the Skybox at particular camera angles and distances. So bring everything down in scale if possible to make more room inside the limits of the Skybox perimeter.
Next try this: set .infiniteDistance = true to keep the Skybox away from the camera, and also set .renderingGroupId = 0 on the Skybox. Lastly, set .renderingGroupId = 1 or more, on all the models and objects to help stop them from disappearing into thin air.
var skybox = BABYLON.MeshBuilder.CreateBox("skyBox", {size:10000.0},
this.scene);
skybox.infiniteDistance = true;
skybox.renderingGroupId = 0;
...and for models and sprite objects...
myModel.renderingGroupId = 1; /* greater than 0 */
These little tricks helped me to achieve a to-scale solar system simulation, but may not work in all cases.
Hello you need to increase camera.maxZ to a value larger than your skybox.

Small issue with R plot - lines() stop before end value

I am in the process of making a nice graph but I encountered an issue with the extremities of the lines I drew. I do not know why R does not plot the lines all the way until maxxx (10 here). You can see on the graph from the code below what I am talking about (I cannot put picture as my reputation is too low), the extremities of the lines stop before 10:
maxxx<-10
plot(0,type="n",axes=FALSE,xlim=c(0,10),ylim=c(0,10),ylab="",xlab="")
mtext("TROLOLOL",side=3,cex=3)
axis(1,pos=0,at=c(0,10),labels=FALSE)
mtext("R1 ",side=1,line=0,cex=3)
axis(2,pos=0,at=c(0,10),labels=FALSE)
mtext("R2",side=2,line=0,cex=3)
Given_growth_rates<-c(0,0.3,0.5,1,2,5);
K1<-7
g1<-5.5
m<-0.2
R1_isoclines<-numeric(length(Given_growth_rates))
for (i in 1:length(Given_growth_rates)){
R1_isoclines[i]<-((Given_growth_rates[i]+m)*K1)/(g1-Given_growth_rates[i]-m)
}
R1_isoclines
K2<-10
g2<-7
R2_isoclines<-numeric(length(Given_growth_rates))
for (i in 1:length(Given_growth_rates)){
R2_isoclines[i]<-((Given_growth_rates[i]+m)*K2)/(g2-Given_growth_rates[i]-m)
}
R2_isoclines
for (i in 1:length(R1_isoclines)){
lines(rep(R1_isoclines[i],times=length(R2_isoclines[i]:maxxx)), R2_isoclines[i]:maxxx, col=i+1, type="l")
lines(R1_isoclines[i]:maxxx,rep(R2_isoclines[i],times=length(R1_isoclines[i]:maxxx)),col=i+1,type="l")
}
Try to replace the last four lines of your code by:
for (i in 1:length(R1_isoclines)){
lines(rep(R1_isoclines[i],times=2), c(R2_isoclines[i],maxxx), col=i+1, type="l")
lines(c(R1_isoclines[i], maxxx), rep(R2_isoclines[i],times=2),col=i+1,type="l")
}
Maybe that does what you expect.

Resources