Julia sets
Author |
Message |
MysticAngel
|
Posted: Wed Mar 26, 2003 6:45 pm Post subject: Julia sets |
|
|
i think i know how to do the julia sets. but i keep getting errors that x and y have been previously declared, but i want to use x and y variales. what to do?
var p : real
var q : real
var maxcount : int
var x, y : int := 1
var imaxx : real
var imaxy : real
var rx, rx2 : real
var ry, ry2 : real
var iwin2 : int
var count : int := 0
var c : int
put "Please enter a value for p"
get p
put "Please enter a callue for q"
get q
put "Please enter a range between 20 to 200)"
get maxcount
imaxx := p
imaxy := q
iwin2 := Window.Open ("graphics : 500; 500,nocursor")
Window.Select (iwin2)
for x: 0.. imaxx
for y : 0.. imaxy
rx := 3.5 / imaxx * x - 1.75
ry := 3.5 / imaxy * y - 1.75
end for
end for
loop
count := count + 1
rx2 := rx * rx - ry * ry + p
ry2 := 2 * rx - ry + q
rx := rx2
ry := ry2
if count > maxcount then
count := count + 55
else
count := 0
end if
c := count
Draw.Dot (i, i2, c)
exit when rx * rx + ry * ry > 4 or count = maxcount
end loop |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Wed Mar 26, 2003 6:50 pm Post subject: (No subject) |
|
|
thats because you're tring to run a for loop using X and Y, though they were previosly decleared. So you ether dont declear X and Y as variables (for loops do that for you) or use another varaible for the loops.
Though I dont get it... counter in for loop is local and cant be accessed from outside the loop... so I donno why they would have a problem with it "being decleared already"... I assume just to keep people from programming the way OTHER then they want |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
MysticAngel
|
Posted: Wed Mar 26, 2003 7:04 pm Post subject: (No subject) |
|
|
k i what i did was that i removed the var statements that declared the variables. now i am getting a big statement error.
var p : real
var q : real
var maxcount : int
var imaxx : real
var imaxy : real
var rx, rx2 : real
var ry, ry2 : real
var iwin2 : int
var count : int := 0
var c : int
put "Please enter a value for p"
get p
put "Please enter a callue for q"
get q
put "Please enter a range between 20 to 200)"
get maxcount
imaxx := p
imaxy := q
iwin2 := Window.Open ("graphics : 500; 500,nocursor")
Window.Select (iwin2)
for x : 0 .. imaxx
for y : 0 .. imaxy
rx := 3.5 / imaxx * x - 1.75
ry := 3.5 / imaxy * y - 1.75
end for
end for
loop
count := count + 1
rx2 := rx * rx - ry * ry + p
ry2 := 2 * rx - ry + q
rx := rx2
ry := ry2
if count > maxcount then
count := count + 55
else
count := 0
end if
c := count
Draw.Dot (i, i2, c)
exit when rx * rx + ry * ry > 4 or count = maxcount
end loop |
|
|
|
|
|
Dan
|
Posted: Wed Mar 26, 2003 7:31 pm Post subject: (No subject) |
|
|
p, q, imaxx and imaxy shode be ints
and you did not deacler i or i2 as anything
also the 1st for loop dose not relay do anything becuse it keeps storing it in rx and ry wich are then chaged to somting eltes in the next loop. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
MysticAngel
|
Posted: Wed Mar 26, 2003 7:35 pm Post subject: (No subject) |
|
|
but they have to be real as the input for x and y will be like 0.365478, 0.63697.......... |
|
|
|
|
|
Asok
|
Posted: Wed Mar 26, 2003 9:05 pm Post subject: (No subject) |
|
|
you cannot make a real variable the counter of a for loop my suggestion would be to make a variable that is equal to round(whatever) |
|
|
|
|
|
MysticAngel
|
Posted: Wed Mar 26, 2003 10:00 pm Post subject: (No subject) |
|
|
i didnt understand it. how would frame the code????
var p : real
var q : real
var maxcount : int
var imaxx : real
var imaxy : real
var rx, rx2 : real
var ry, ry2 : real
var iwin2 : int
var count : int := 0
var c : int
var x, y : int
put "Please enter a value for p"
get p
put "Please enter a callue for q"
get q
put "Please enter a range between 20 to 200)"
get maxcount
imaxx := p
imaxy := q
iwin2 := Window.Open ("graphics : 500; 500,nocursor")
Window.Select (iwin2)
for x: 0 .. imaxx
for y : 0 .. imaxy
rx := 3.5 / imaxx * x - 1.75
ry := 3.5 / imaxy * y - 1.75
end for
end for
loop
count := count + 1
rx2 := rx * rx - ry * ry + p
ry2 := 2 * rx - ry + q
rx := rx2
ry := ry2
exit when (rx * rx + ry * ry) > 4 or count = maxcount
if count > maxcount then
count := count + 55
else
count := 0
end if
c := count
Draw.Dot (x, y, c)
end loop |
|
|
|
|
|
MysticAngel
|
Posted: Thu Mar 27, 2003 9:04 pm Post subject: (No subject) |
|
|
i wanted to know whether there was any posts on GCD and LCM. i think i saw it. but i browsed thorugh a few pages of the post but coudnt find it. did anyone had any post about GCD and LCM ? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|