|
-
Apr 3rd, 2003, 01:21 AM
#1
I cant figure out this algorithm
I have a funtion drawing() like this:
Code:
private sub drawing()
max = calculate_max() 'determine max hight
min=calculate_min() 'min height
Me.ScaleHeight = (2.2 * (max - min))
me.refresh
vertical_coordinates <-----problem
draw things here.....
end sub
Eash time user puts a new terrain point (distance and height) in a Flexgrid and press ENTER this function is executed to resize and redraw.
Vertical Coordinates are the Y coordinates of the draw, that is
enclosed in a square i draw that is almost half the size of the screen. Look:
IMAGE LINK
Well, I cant show good coordinates where it says "here!"
I mean: there coord shoud be like 5 - 10 - 15 etc..
or 10-20-30. .etc
but with some numbers im getting somethig like:
21- 42- 63 (1 each 20).
OR: 547- 637- etc..
I need this coordinates to be rounded numbers like:
10, 15, 20... or 100, 200, 300.....or 540, 560, 580, etc
im trying something like:
Code:
dim hight as double
dim number as long
hight = max-min
do while max/10 <>int(max/10) 'is max divisible per 10
max=max+1
loop
hight=max-min 'recalculate
number=hight/10
do while min/10 <>int(min/10) 'is min divisible per 10
min=min-1
loop
hight=max-min 'recalculate
number=hight/10
now number has the distance between coordinates and I can
do something like this with each label:
Label1.Top = -min - number * 1 '
Label1.Caption = Str(min + number * 1)
.....
'(with each label)
'Here I use -min to start just
'in the bottom of the square, where the min is, and values are
'negative cause thats the way to go up in my form (incresing
'negative values
This is not working, im getting bad coordinates, like i said before.
Any idea about an algorithm to do this???
Thanks!
JCI
Last edited by jcis; Apr 3rd, 2003 at 10:50 AM.
-
Apr 3rd, 2003, 09:55 AM
#2
This line in your code looks suspect:
Code:
do while max/10 <>int(high/10) 'is max divisible per 10
max=max+1
loop
It will just loop round until max=high (or forever if max was already greater than high).
Try this instead:
Code:
max = ( max \ 10 ) * 10
The \ operator is integer division (in case you didn't know that).
There is a similar error later on in the code as well.
This world is not my home. I'm just passing through.
-
Apr 3rd, 2003, 11:00 AM
#3
thats the way it is
Code:
do while max/10 <>int(max/10) 'is max divisible per 10
max=max+1
loop
hight=max-min 'recalculate
number=hight/10
do while min/10 <>int(min/10) 'is max divisible per 10
min=min+1
loop
hight=max-min 'recalculate
number=hight/10
This is the way i had it in my program, i just make a mistake when
i wrote the code again here.
The problem with this, is that I cant get good numbers, i mean:
example:
max:510
min=0
max will still be 510 and min will still be 0
max-min=510
then 510/10=51
and coordinates will then be:
-306
-255
-204
-153
-102
-51
(Horrible!)
I need something like:
-400
-350
-300
-250
-200
-150
-100
-50
(this is just 1 example) sometimes number should be 50, others
10, or 100, or 2, or 3, or 5, or , or 500, 1000. That kind of number
would give razonable coordinates.
JCI
-
Apr 3rd, 2003, 03:20 PM
#4
did you even look at the reply I posted on your identical question in the General section?
it showed the way to start with "even"coordinates.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|