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" <[email protected]> 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 <[email protected]> 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 ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/quartzcomposer-dev/achim%40boinx.com
>>
>> This email sent to [email protected]
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]