• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

algorithm..

imported_vr6

Platinum Member
Software forum is flooded with doom3 threads so i thought i give it a try here.

A circle 0-360 degrees

I need to divide it, Up to 8 sections
- Cannot overlap
- can be any range
ex.
Section1: 345-55
or
section1: 355 - 340
or
section1: 90-240, etc.

- if a new section is to be created within another section, i must divide the section
for example.
section 1 : 90-270
new section = 140-200
result:
section1: 90-139
section2: 140-200
section3: 201-270, section three will hold the same attibutes as section1, just range difference.

-if a new section will cover part of an existing section, then shift the start/end range of existing section accordingly.

How would you do it?
 
Comming from Java, I would make a cricle object and it would hold an indefinent amount of sections. It would have a method to create new section objects which would alter them if needed. Each section object would have the apropriate methods to give the range. It would be the circles job to make sure they did not over lap or exceed 8.
 
Are you trying to draw a pie graph, or what? Just draw lines from your center point to the edge of the circle at whatever degree measurement you need. If the polar coordinates are confusing you:

x = r cos theta, y = r sin theta

Where r is the radius of your circle, and theta is your angle. (you should have learned that in high school).
 
no, i am writing code to help simulate the controls for a radar in VB6.

There will be no graphical display, numerical display of the ranges to ensure no overlapping have occured.
 
Can't you just have a list of up to 8 angles then?

each angle must be greater than the last angle, and the last angle must be less than the first angle + 360.

section1 = angle[0] to angle[1]
section 2 = angle[1] to angle[2]
etc...

That keeps track of up to 8 sections. If you split a section, all you do is insert a new angle at the proper place in the list.
 
Originally posted by: notfred
Can't you just have a list of up to 8 angles then?

each angle must be greater than the last angle, and the last angle must be less than the first angle + 360.

section1 = angle[0] to angle[1]
section 2 = angle[1] to angle[2]
etc...

That keeps track of up to 8 sections. If you split a section, all you do is insert a new angle at the proper place in the list.

yea i'm with him... just figure out the angles beforehand... i mean with just 8 sections its not like you need to worry about runtime or anything so just do it the programatically easiest way
 
That would require more then 8 angles 0 to 8 = 9 angles no?

section1, section2, section3, section4, section5, section6, section7, section8
[0]-[1], [1]-[2] , [2]-[3] , [3]-[4] , [4]-[5] , [5]-[6] , [6]-[7] , [7]-[8]

Then i would also have to keep track of how many of the angles are active.

Heres what i planned to do

an array(0 to 360) of UDT, what has 2 elements, section, and attrbutes.
The section keeps tracks of what section the array element is assigned to and the attributes tells what the previous section of the array element if it a new section split an existing section in half.

I do like the angle idea, but i have to do more thinking since i do not fully understand it yet, but it does look like it feasible.
 
Back
Top