Sorting all cells by values in one plane
Quick background on this idea – I’m building a lighting control system that uses a 5-plane matrix (A,R,G,B, lighting fixture index) to drive lighting fixtures using arbitrary 2D RGB info. The 2D ‘space’ is represented as the floorplan of a venue where the ceiling is sprinkled with about 300 RGB LED fixtures. I’m laying out the LED distribution on the floorplan by sparsely populating the 5th plane of my matrix with lighting fixture indices in the appropriate locations.
The idea is that the ARGB part of the matrix can be used to generate and visualize arbitrary color content and then to subsample that color information, formatting DMX messages to the lights using the addresses in the index plane.
I underestimated the complexity of sorting the matrix based on the index plane values. I had thought I’d run some jit sort (like jit.bsort) on the index plane (sorting the ARGB info along with it), and then pull the bottom 300 or so cells from that sort (0 – number of fixtures-1) and use the ARGB info to generate DMX commands, all hopefully at a decent refresh rate.
jit.bsort sorts on only one axis at a time. My CS days were a while ago but I think I’d need to cascade some fairly significant number of jit.bsorts in order to get the result I’m looking for. Undesirable from a processor overhead standpoint.
I can make this happen without actually sorting the values – I really need only to select cells that have non-zero values in the index plane – but my iterative thinking doesn’t map well to the way jitter objects work.
Can anybody advise on a best way to approach this? Pseudocode-wise, I’m thinking:
1) Take a 5-plane matrix as input (resolution of original matrix is roughly 560 x 820)
2) Select cells that have non-zero value in the 5th (index) plane
3) Extract ARGB information from those cells, coupled with their index values
4) Make available those (300-ish) 5-value lists (per frame) at a reasonable rate (~40Hz)
Thanks for any help in advance!
if you don’t have to be exact (meaning you simply want the 300 or whatever highest index values), you can cascade two jit.bsorts and send the result to jit.submatrix. also check out the 3rd party xray externals for xray.jit.quicksort, which may be faster.
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 622.3oc0WssahCCD84juBq7LKJ14BI6S8qXeYUUkShoXDwNx1ovtU8ee8kDt rBBADzREPL1wLybN9LyDd22KnfugHC.+D7afm269dd1kLK30M2KnFuobEVZ2 VvRpZZyZJqhuNXh69MXU4BJ60WDjRkyVYggSCm.PItgX6.LSO.dt6WQqr1iW r7Go8Vh0VSYqHJqqf6Vj2p5WE06TAQRXJrhxYG3XjywwlgvtKacpyPp+zPba OHXh9C3Yyc+v22bYxHIBFYsN16ibEYiZK+HaKpwJAcC3oJZMHS+5I974RhBf .nAnsYy1QTZPfrf.AONqkzan4blhgqsPJ3WDQElguBF0XFI8uVy.Mr3InLMB ewAuqm7FmJJI9RTQw2NUTZ39G.eQpnBIWnrJnZdEA.GfnhQNpIxMDmaGlsWH WxWwEtMCcvIKODlmZAV22NgNK5NpyxuuxrhVkhyFf3foVFqSms85wnAzE.U3 o.UAl858LiAkE4RURGSFCb1Ub7cCE+iCSQ4WBjx9Zgz4xmG.m4N4GzdB5lbq RgiS99lCO.ix3TotvHnbAV.fg52mkdgcUJSRFp0ZJ7Ar2pMPCVQY++CrYAqY 8CYQIuUT1a3tGX.rCtUDohxrc91aOoGrmEzpJh818QbEUhKVQrTU3QOMGazD MhnI4gJZh+zhl3wbTE8XENllICFO0zpFNko5Tu44SSzYfcU2yQamsyO2L.Xx mO+w6mmZaTwioU1kSnvD6e.JNa6j6.ehFSkD3URmt5b3ll2HBYmMsQhtuvRW GvzI1oTlaps1aff7Fse+Q1UvBcS.ktCPqvU.eSVZfuwOe3+OIuib0B -----------end_max5_patcher-----------
if you need to be exact, then you’re probably going to have to use jit.iter or jit.spill.
Hey thanks Rob! I think you’re right about that … the problem is simpler than I thought.
Forums > Jitter