Hi Achim, Thanks a lot, I'll test later in the day. At a glance it looks like the missing link I need. I'm working on a comp to mask, crop, write to file, scan and reassemble fragments of images/movies (so I actually need the 2D bounding box first).
Jerry On 5/11/11 7:58 AM, "Achim Breidenbach" <ac...@boinx.com> wrote: > Hi Jerry, > > I am not sure what you are trying to archive, but if you want to find the > bounding box for a 3D object defined by 3 points, you have to evaluate the > min/max for each component separately. Also you have to compare each point > against the current min/max you already calculated: > > something like this: > > _Mins = new Array(9999,9999,9999); > _Maxs = new Array{-9999,-9999,-9999); > > for(var point=0; point<Points.length; point ++){ > > for(var component=0 ; component<3; component ++){ > > if( _Mins[component] > Points[point][component]){ > _Mins[component] = Points[point][component]; > } > if( _Maxs[component] < Points[point][component]){ > _Maxs[component] = Points[point][component]; > } > > } > > } > > > Please note: This is untested code, I just typed it in the email. (missing all > the "main-function"-wrapping) > > The result is a _Mins and _Maxs array having 3 components each, containing the > min and max values for x , y and z of all points. Makes six numbers total. Is > this what you need? > > best, > > Achim Breidenbach > Boinx Software > > > > On 11.05.2011, at 11:07, Jerry Smith wrote: > >> Here's another revision, still the same problem. Not yet getting something >> crucial: >> >> _Mins = [] >> _Maxs = [] >> >> function (__structure min, __structure max) main (__structure Points) >> { >> var result = new Object() >> if (Points != null) { >> >> for (var i=0; i < Points.length; ++i) { >> _Mins = [Math.min(Points[0][0], Points[i][0]), >> Math.min(Points[0][1], Points[i][1])]; >> } >> >> for (var j=0; j < Points.length; ++j) { >> _Maxs = [Math.max(Points[0][0], Points[j][0]), >> Math.max(Points[0][1], Points[j][1])]; >> } >> } >> result.min = _Mins; >> result.max = _Maxs; >> return result >> >> } >> >> >> >> >> On 5/10/11 11:05 PM, "Achim Breidenbach" <ac...@boinx.com> wrote: >> >>> Hi Jerry, >>> >>> First question: The "m=0" line belongs outside the for-loop for sure, >>> otherwise m will always be 0 or 1 for the following lines, alway >>> overwriting previouse stored _Mins and _Maxs. >>> >>> Also "m++" means increase m after evaluating the code line. In the >>> following line m is 1 and will be increase again. The result is that >>> in the _Mins array only the even idexes get set, and in the _Maxs the >>> odd indexes. I guess you want to change the first "m++" to just "m", >>> but then "m" goes with "i" which means that "m" is obsolete and can be >>> replaced by i. >>> >>> Best, >>> >>> Achim Breidenbach >>> Boinx Software >>> >>> On 11.05.2011, at 02:11, Jerry Smith <je...@sonsmi.com> wrote: >>> >>>> I realize this is double posting from this kineme forum thread: >>>> http://kineme.net/forum/Discussion/General/JavascriptMinMax >>>> >>>> Sorry. In the meantime I reduced the comp to the essential parts. I am >>>> trying to set up an approach to getting a bounding box (and eventually a >>>> cube) for polygons with arbitrary # of points. Comp uses Kineme Structure >>>> Tools and GL Tools. I have 3 questions in order of importance: >>>> >>>> 1. Re: getting the min/max from an array. This js (as well as the attempt >>>> using the iterator in the comp) only grabs the first and last points in the >>>> structure of 4 points. What am I doing wrong here: >>>> >>>> [javascript] >>>> _Mins = [] >>>> _Maxs = [] >>>> >>>> function (__structure min, __structure max) main (__structure Points) >>>> { >>>> var result = new Object() >>>> >>>> if (Points != null) { >>>> for (var i=0; i < Points.length; ++i) { >>>> m = 0 >>>> >>>> _Mins[m++] = [Math.min(Points[0][0], Points[i][0]), >>>> Math.min(Points[0][1], Points[i][1])]; >>>> _Maxs[m++] = [Math.max(Points[0][0], Points[i][0]), >>>> Math.max(Points[0][1], Points[i][1])]; >>>> >>>> } >>>> } >>>> result.min = _Mins; >>>> result.max = _Maxs; >>>> return result >>>> >>>> } >>>> [/javascript] >>>> >>>> 2. How can I send points in order to keep mesh corners from folding over? >>>> >>>> 3. In the number stats display, how can I truncate to decimal places and >>>> avoid the jumps caused by floating point error? >>>> >>>> <StructMinMax2.qtz> >>>> _______________________________________________ >>>> Do not post admin requests to the list. They will be ignored. >>>> Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com) >>>> Help/Unsubscribe/Update your Subscription: >>>> http://lists.apple.com/mailman/options/quartzcomposer-dev/achim%40boinx.com >>>> >>>> This email sent to ac...@boinx.com >>> >> >> > > _______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com