TheSwamp

Code Red => .NET => Topic started by: nobody on June 20, 2016, 10:31:11 PM

Title: Quadrants
Post by: nobody on June 20, 2016, 10:31:11 PM
I need to write code to determine the two quadrants for two lines at different bearings....but can't wrap my head around how many cases will be possible so I can be sure I'm accounting for them all... anyone know this already?

quadrant being north, south, east, west

see attached image, and thanks!

Title: Re: Quadrants
Post by: kdub_nz on June 20, 2016, 10:59:58 PM
Could both vectors point into the same quadrant in your world ??

ie: 1 o'clock and 2 o'clock etc ?
Title: Re: Quadrants
Post by: kdub_nz on June 20, 2016, 11:07:10 PM
Ignoring the order the vectors are considered in :
I believe the short answer is 10

Opposite Quadrant : 2 options
Adjacent Quadrant   : 4 options
Same Quadrant     : 4 options

added:
and ignoring the Cardinal directions.
Title: Re: Quadrants
Post by: nobody on June 21, 2016, 01:29:06 AM
Could both vectors point into the same quadrant in your world ??

ie: 1 o'clock and 2 o'clock etc ?

crud they can :/
Title: Re: Quadrants
Post by: nobody on June 21, 2016, 01:51:14 AM
Ignoring the order the vectors are considered in :
I believe the short answer is 10

Opposite Quadrant : 2 options
Adjacent Quadrant   : 4 options
Same Quadrant     : 4 options

added:
and ignoring the Cardinal directions.

oy... good point with the cardinal directions :/  this is going to be harder than anticipated
Title: Re: Quadrants
Post by: kdub_nz on June 21, 2016, 02:14:53 AM

I'm more than just a pretty face with a questionable sense of humour :)
Title: Re: Quadrants
Post by: roy_043 on June 25, 2016, 08:57:10 AM
If the quadrants are north, east, south and west I would argue that 1 o'clock and 2 o'clock are not in the same quadrant.
Title: Re: Quadrants
Post by: kdub_nz on June 25, 2016, 09:46:34 AM
whatever,
but I'd wager that's not the case.

If you look at his piccy the Cardinal directions appear to be at 12, 3, 6, 9 ... but I've been wrong before :)
and the proposition about 2 vectors in the same quadrant holds.
Title: Re: Quadrants
Post by: nobody on June 25, 2016, 11:06:30 PM
whatever,
but I'd wager that's not the case.

If you look at his piccy the Cardinal directions appear to be at 12, 3, 6, 9 ... but I've been wrong before :)
and the proposition about 2 vectors in the same quadrant holds.

Correct...12,3,6,9.... but thanks all, I'm abandoning the cause... there are far too many conditions to account for.... not worth the effort. Not only can the vectors be opposite, vertical / horizontal, but acute angles and both vectors heading toward the same quadrant....I'll need to try and figure out a different way to address the problem :/ 
Title: Re: Quadrants
Post by: kdub_nz on June 25, 2016, 11:27:00 PM
Finally, we come to the issue :

Quote
I'll need to try and figure out a different way to address the problem

What is the problem ?

The Conditionals are known.
The Vectors are calculatable.
Seems to me the issue is lexical (naming the unique conditions ) rather than mathematical or logical.
Title: Re: Quadrants
Post by: roy_043 on June 26, 2016, 07:43:37 AM
If you look at his piccy the Cardinal directions appear to be at 12, 3, 6, 9 ... but I've been wrong before :)
and the proposition about 2 vectors in the same quadrant holds.
... The issue is indeed about definitions. IMO the north sector is bisected by the north direction. So assuming 12 o'clock is north, 1 and 2 o'clock are not in the same sector.
Code: [Select]
NW > north sector >= NE
Title: Re: Quadrants
Post by: nobody on June 26, 2016, 01:11:10 PM
Finally, we come to the issue :

Quote
I'll need to try and figure out a different way to address the problem

What is the problem ?

The Conditionals are known.
The Vectors are calculatable.
Seems to me the issue is lexical (naming the unique conditions ) rather than mathematical or logical.
I'm not sure I have all the possible scenario's accounted for graphically...which makes it that much more difficult to do it programmatically... :/ 



Title: Re: Quadrants
Post by: roy_043 on June 28, 2016, 04:20:28 AM
If you limit the orientation of the lines to N, NE, E etc., consider N+NE to be equal to NE+N etc., and include the cases where the lines are superimposed, there a [8*8]/2 = 32 combinations.
Title: Re: Quadrants
Post by: MickD on June 28, 2016, 09:00:39 PM
Can't you use the angle of the lines in radians to determine quadrant? or am I missing something? (probably :) )

eg. 0 -> pi/2 is quadrant from 12 o'clock to 3 o'clock, pi/2 -> pi = 9-12 o'clock, pi -> 3pi/2 = 9-6 o'clock and 3pi/2 -> 2pi = 6-3 o'clock.

obviously you will need to rationalise what happens at 3, 6, 9 and 12 o'clock positions.
Title: Re: Quadrants
Post by: kdub_nz on June 29, 2016, 11:19:18 PM
Try this :
Note: Check the Bit values for veracity ... I rushed this a little

Title: Re: Quadrants
Post by: roy_043 on June 30, 2016, 04:58:51 AM
If you limit the orientation of the lines to N, NE, E etc., consider N+NE to be equal to NE+N etc., and include the cases where the lines are superimposed, there a [8*8]/2 = 32 combinations.
:embarrassed: Oops. I stand corrected. As Kdub demonstrates there are 36 combinations.

https://www.mathsisfun.com/combinatorics/combinations-permutations.html
Title: Re: Quadrants
Post by: nobody on June 30, 2016, 09:56:09 AM
Try this :
Note: Check the Bit values for veracity ... I rushed this a little

Thank you kdub!
Title: Re: Quadrants
Post by: kdub_nz on June 30, 2016, 08:03:36 PM

You're welcome.

Perhaps the assignment of bit values would be more logical if E=1 , N=2 etc progressing counter-clockwise with the increased angular value ; similarly with quadrant nominations.