We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my code is here if can't solve my problem please give tips for me to walk in another way,thanks in advance.
int leth=1,sze_X=900,sze_Y=600;
float center_X=sze_X/3,center_Y=sze_Y/3,ellipse_center_X=center_X+50,ellipse_center_Y=center_Y,equation_c;
float x[]=new float[leth],y[]=new float[leth],size_1[]=new float[leth],step[]=new float[leth],angle[]=new float[leth],equation_a[]=new float[leth],equation_b[]=new float[leth],equation_A[]=new float[leth],equation_B[]=new float[leth],equation_C;
double ellipse_a[]=new double[leth],ellipse_b[]=new double[leth];
boolean negation_X[]=new boolean[leth],negation_Y[]=new boolean[leth];
void setup(){
size(sze_X,sze_Y,OPENGL);
background(0);
smooth(8);
noStroke();
rdm();
equation_c=dist(center_X,center_Y,ellipse_center_X,ellipse_center_Y);
eqt();
println(equation_A+","+equation_B+","+equation_c+",");
step[0]=0.01;
}
void rdm(){
int half_size=45;
for(int i=0;i<leth;i++){
x[i]=random(-sze_X,sze_X);
y[i]=random(-sze_Y,sze_Y);
if(center_X-half_size-13<=x[i]&&x[i]<=center_X+half_size+13){
if(center_Y-half_size-13<=y[i]&&y[i]<=center_Y+half_size+13){
while(center_Y-half_size-13<=y[i]&&y[i]<=center_Y+half_size+13){y[i]=random(0,sze_Y);}
}
}
size_1[i]=random(5,13);
}
x[0]=100;
y[0]=100;
size_1[0]=30;
}
void eqt(){
for(int i=0;i<leth;i++){
equation_A[i]=sq(equation_c)*sq(x[i]);
equation_B[i]=sq(x[i])+sq(y[i])+sq(equation_c);
equation_C=1;
if((equation_B[i]-sqrt(sq(equation_B[i])-4*equation_A[i]*equation_C))>=0){equation_a[i]=1/((equation_B[i]-sqrt(sq(equation_B[i])-4*equation_A[i]*equation_C))/2*equation_A[i]);}
else if((equation_B[i]-sqrt(sq(equation_B[i])-4*equation_A[i]*equation_C))<0){equation_a[i]=1/((equation_B[i]+sqrt(sq(equation_B[i])-4*equation_A[i]*equation_C))/2*equation_A[i]);}
else{println("@@@@@@@@@@@@@@@@@@");}
equation_b[i]=equation_a[i]-sq(equation_c);
ellipse_a[i]=sqrt(equation_a[i]);
ellipse_b[i]=sqrt(equation_b[i]);
}
}
void draw(){
color blk=color(0,0,0);
color blu=color(100,255,252);
int size=100;
float number=0.01;
color change=lerpColor(blk,blu,0);
clear();
for(int i=0;i<100;i++){
if(number<=1){
change=lerpColor(blk,blu,number);
number=number+0.01;
fill(change);
}
else{
fill(blu);
}
if(size>0){
ellipse(center_X,center_Y,size,size);
}
size=size-1;
}
star();
rotte();
}
void star(){
color blc=color(0,0,0);
color org=color(255,252,45);
float size_2=5.0;
float number;
color change;
for(int i=0;i<leth;i++){
size_2=size_1[i];
number=0;
for(int j=0;j<size_1[i];j++){
if(number<=1){
change=lerpColor(blc,org,number);
number=number+1/size_1[i];
fill(change);
}
else{
fill(org);
}
if(size_2>0){
if(negation_X[i]==true){
if(negation_Y[i]==true){ellipse(-x[i],-y[i],size_2,size_2);}
else{ellipse(-x[i],y[i],size_2,size_2);}
}
else{
if(negation_Y[i]==true){ellipse(x[i],-y[i],size_2,size_2);}
else{ellipse(x[i],y[i],size_2,size_2);}
}
ellipse(x[i],y[i],size_2,size_2);
negation_X[i]=false;negation_Y[i]=false;
}
size_2=size_2-1;
}
}
}
void rotte(){
int i;
for(i=0;i<leth;i++){
x[i]=(float)(y[i]+ellipse_a[i]*cos(angle[i]));
y[i]=(float)(x[i]+ellipse_b[i]*sin(angle[i]));
angle[i]+=step[i];
if(angle[i]>TWO_PI){angle[i]-=TWO_PI;}
if(x[i]<0){negation_X[i]=true;x[i]=-x[i];}
else if(y[i]<0){negation_Y[i]=true;y[i]=-y[i];}
else{negation_X[i]=false;negation_Y[i]=false;}
}
}
Answers
here...........................
Did you mean this?
you could also save the ball as an image and then display this - faster
I want to change its size and the number of it if I want so I wrote this code,but the point is how to make it run with an ellipse track
you need to be more precise with your questions I am afraid...
Do you mean the form of the ball itself should be like an ellipse?
the ball‘s center is in ellipse track and the properties of ellipse can be change,so that to create new shape of ellipse for the center goes in
here....
Sorry my meaning is the yellow ball move in the ellipse track , with one focus had set and one i can set arbitrarily (from setting the ellipse's center(ellipse_center_X,ellipse_center_Y)) , i want the computer to calculate it so i give the equation (equation_a[]=new float[leth], equation_b[]=new float[leth], equation_A[]=new float[leth], equation_B[]=new float[leth], equation_C;)
maybe i didnt describe what i want clearly , so please help me again, thanks!
nobody can?
I don't get your english...
Let me quote you and ask what you mean...
Do you want that the yellow ball moves towards the blue ball?
Do you mean the x- or y-value of the yellow ball is fixed? Because it has no focus.
What do you want to achieve by this?
Draw an ellipse with nothing fill in, regard it as the track of yellow ball ,but I want the track(ellipse)can be user-defineded , so I created an ellipse_center ,but how can I make the computer creat by itself?so I used my math knowledge to calculate it and give the final equation,so that the computer can calculate the point(the axis a and b of the ellipse)from
origin of coordinates I give (change a way to say I give the center and the The elliptical focal length from the length to calculate other two key axis a and b) ,and after done that I can use the yellow ball's x,y and the center to move it in the ellipse.
I asked you 3 questions, could you answer all 3 questions, please?
here
when you click left mouse, ellipse is at this position
whenn you click right mouse, you set radius in x and y of the ellipse
http://postimg.org/image/mixyssuj9/
the picture of my meaning
who can help me????
I hope there's someone can help me out
I have no idea.... sry....
you can use a drag and drop with the mouse on the blue ball. Do you want that? The 2nd focus of the ellipse should then be fixed? ok, I don't have the math for your idea. The math I have at my command you see above. it works with sin, cos and different radius for both.
see you
From your drawing it is absolutely unclear what you're trying to accomplish.
Maybe you can draw several http://sketchtoy.com/49496868 sketches, to show us the dynamics of what you're trying to accomplish. You don't have to draw doraimon but just few drafts of movements of your ellipses.
http://sketchtoy.com/52430993
you didn't answer my question. you can use a drag and drop with the mouse on the blue ball. Do you want that?
first question is No, i want to change leth and remove x[0]=100;y[0]=100;size_1[0]=30; to get hundreds of yellow ball , the blue ball is static and its center is the focus of the ellipse, all can be changed is the center, once set the center ,the another focus will be set and be fixed at the same time and the computer will know what the ellipse like automaticly,so the second question is Yes.maybe my equation is wrong please check it , sorry for ignored.
Stop rejecting replies that aren't even answers! It becomes on the verge of being offensive...
I don't have the math for this. But I think what the guy wants it that he can let the user change an existing ellipse on which a yellow ball spins around. One focus of the ellipse is fixed, the other focus is the blue ball and when the user drags the blue ball, the ellipse changes. Or the user can set first the left focus, then the right one?
Maybe something like this:
Shame on me, I didn't read the whole thing before posting. Maybe this could be a start for what OP wants though.
here
you can place one ball
place the other ball (same Y)
and then ellipse starts
also you can drag both balls (only X)
Hello! I haven't understood your formula, partly because of your language and your use of abbrevations... what means leth? Angle? rdm? rotte? eqt? Also equation_A[i]= ... this is not a helpful name. What is the purpose of the equation? That would be a better name... Thank you! Chrisir
closed i am having a nother topic to replace this one
Closed, ok.
But what's missing in my program?