Click here to Skip to main content
15,912,932 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Steganography algorithms?? Pin
Vasudevan Deepak Kumar17-Jul-07 6:45
Vasudevan Deepak Kumar17-Jul-07 6:45 
Questionlinear algebra library Pin
ovoundaga8-Jul-07 2:03
ovoundaga8-Jul-07 2:03 
AnswerRe: linear algebra library Pin
Stephen Hewitt8-Jul-07 15:03
Stephen Hewitt8-Jul-07 15:03 
GeneralRe: I think this shouldn't be here... Pin
p_v_chaitanya2-Jul-07 1:51
p_v_chaitanya2-Jul-07 1:51 
AnswerI think this shouldn't be here... Pin
CPallini2-Jul-07 1:47
mveCPallini2-Jul-07 1:47 
QuestionQuick Hit-Testing Pin
Ri Qen-Sin19-Jun-07 3:43
Ri Qen-Sin19-Jun-07 3:43 
AnswerRe: Quick Hit-Testing Pin
Luc Pattyn19-Jun-07 4:30
sitebuilderLuc Pattyn19-Jun-07 4:30 
GeneralRe: Quick Hit-Testing Pin
Ri Qen-Sin19-Jun-07 6:09
Ri Qen-Sin19-Jun-07 6:09 
Thank you for your input. I have already thought about SCHEME 1. The problem is, the circles are not static. They move around. They represent players on a map, and the line represents the path that a bullet takes.

After some more thought about the problem, I realized that while we can't elimenate unnecessary tests altogether, we can cut out a good portion of the tests in some circumstances. This might involve maintaining certain properties before the actual hit testing occurs (like how order is maintained for a balanced search tree before a search is performed).

I will outline my approach below (and you can judge my methods):

  • A rectangular plane (named: MAP) is created which everything else will be relative to.
  • MAP is subdivided into regions. These regions are squares. They contain references to circles. The length and width of the region are set such that it is not smaller than the largest diameter of a circle. These regions are addressed by indices. The indices are directly related to the region's offset from the origin on MAP.
  • A circle (named: CHAR1) is created on MAP with a radius no greater than half a region's length. (This is important later on when we try to determine what regions get tested.)
  • CHAR1 is added to the region that it is in. (The circle's boundaries may cross into one or more other regions.) Its region will now have a reference to it.
  • CHAR1 moves and it crosses its region's boundaries. It has crossed into another region, so the region's references to CHAR1 are deleted, and the current region CHAR1 resides in creates a reference to CHAR1. (Regions are synchronized with the circle's location.)
  • Another circle (named: CHAR2) is created on MAP. It fires a projectile that follows a line (named: PATH).
  • Now here is the tricky part (I don't even know if it works.):

    • With PATH defined by y = mx + b, create 2 more lines that are parrallel to PATH and are separated by an a perpendicular distance that is equal to the greatest possible radius of a circle (a limit which is artificially imposed). The lines are created on with sides of PATH. The three lines intersect all the regions that should be tested. (Hit-testing with squares should be much more efficient than hit testing with circles.)
    • So now that we have 3 lines, we just plugin values for X in increments of the width of the region starting from the position of CHAR2. We get coordinates that hit every region that needs to be tested. Suppose the indices of the regions use the format [x, y] in increments of 1, and region's corner defined by it's coordinates multiplied by the region length/width, then we could do an integer division on the coordinates given by plugging in X values into the line equations and get the regions that should be tested.





ROFLOLMFAO

GeneralRe: Quick Hit-Testing Pin
Luc Pattyn19-Jun-07 6:53
sitebuilderLuc Pattyn19-Jun-07 6:53 
GeneralRe: Quick Hit-Testing Pin
Ri Qen-Sin19-Jun-07 13:30
Ri Qen-Sin19-Jun-07 13:30 
GeneralRe: Quick Hit-Testing Pin
cp987619-Jun-07 18:39
cp987619-Jun-07 18:39 
GeneralRe: Quick Hit-Testing Pin
Luc Pattyn20-Jun-07 1:45
sitebuilderLuc Pattyn20-Jun-07 1:45 
GeneralRe: Quick Hit-Testing Pin
Ri Qen-Sin20-Jun-07 2:59
Ri Qen-Sin20-Jun-07 2:59 
GeneralRe: Quick Hit-Testing Pin
Luc Pattyn20-Jun-07 3:56
sitebuilderLuc Pattyn20-Jun-07 3:56 
GeneralRe: Quick Hit-Testing Pin
Ri Qen-Sin20-Jun-07 14:25
Ri Qen-Sin20-Jun-07 14:25 
GeneralRe: Quick Hit-Testing Pin
Ri Qen-Sin20-Jun-07 2:50
Ri Qen-Sin20-Jun-07 2:50 
AnswerRe: Quick Hit-Testing Pin
Stephen Hewitt20-Jun-07 14:13
Stephen Hewitt20-Jun-07 14:13 
GeneralRe: Quick Hit-Testing Pin
cp987620-Jun-07 17:09
cp987620-Jun-07 17:09 
GeneralRe: Quick Hit-Testing Pin
Stephen Hewitt21-Jun-07 16:30
Stephen Hewitt21-Jun-07 16:30 
GeneralRe: Quick Hit-Testing Pin
cp987623-Jun-07 18:34
cp987623-Jun-07 18:34 
AnswerRe: Quick Hit-Testing Pin
Roy Heil2-Jul-07 3:43
professionalRoy Heil2-Jul-07 3:43 
GeneralRe: Quick Hit-Testing: The "Look and See" Method Pin
Luc Pattyn22-Jun-07 7:00
sitebuilderLuc Pattyn22-Jun-07 7:00 
Questionrunge Kutta Pin
Noharyiasa18-Jun-07 23:46
Noharyiasa18-Jun-07 23:46 
AnswerRe: runge Kutta Pin
Luc Pattyn19-Jun-07 0:11
sitebuilderLuc Pattyn19-Jun-07 0:11 
GeneralRe: runge Kutta Pin
Noharyiasa19-Jun-07 0:21
Noharyiasa19-Jun-07 0:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.