001: /*
002: * $RCSfile: HiResCoord.java,v $
003: *
004: * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.5 $
028: * $Date: 2008/02/28 20:17:23 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import java.lang.Integer;
035: import javax.vecmath.*;
036:
037: /**
038: * High resolution coordinate object.
039: *
040: */
041:
042: /**
043: * The HiResCoord object specifies the location of scene
044: * components within the Virtual Universe.
045: * The coordinates of all scene graph objects are relative to
046: * the HiResCoord of the Locale in which they are contained.
047: * <P>
048: * The HiResCoord defines a point using a set of three
049: * high-resolution coordinates, each of which consists of three
050: * two's-complement fixed-point numbers.
051: * Each high-resolution number consists of 256 total bits with a
052: * binary point at bit 128, or between the integers at index
053: * 3 and 4. A high-resolution coordinate of 1.0 is defined to be exactly
054: * 1 meter. This coordinate system is sufficient to describe a
055: * universe in excess of several billion light years across, yet
056: * still define objects smaller than a proton.
057: * <P>
058: * Java 3D uses integer arrays of length
059: * eight to define or extract a single 256-bit coordinate value.
060: * Java 3D interprets the integer at index 0 as the 32
061: * most-significant bits and the integer at index 7 as the 32
062: * least-significant bits.
063: */
064:
065: public class HiResCoord {
066: /**
067: * The eight-element array containing the high resolution coordinate's
068: * x value.
069: */
070: int x[];
071:
072: /**
073: * The eight-element array containing the high resolution coordinate's
074: * y value.
075: */
076: int y[];
077:
078: /**
079: * The eight-element array containing the high resolution coordinate's
080: * z value.
081: */
082: int z[];
083:
084: private double scales[] = {
085: 79228162514264337593543950336.0, // 2^96
086: 18446744073709551616.0, // 2^64
087: 4294967296.0, // 2^32
088: 1.0, // 2^0
089: 2.3283064365386962890625e-10, // 2^-32
090: 5.421010862427522170037264004349708557128906250000000000000000e-20, // 2^-64
091: 1.26217744835361888865876570445245796747713029617443680763244628906250e-29, // 2^-96
092: 2.938735877055718769921841343055614194546663891930218803771879265696043148636817932128906250e-39 };
093:
094: /**
095: * Constructs and initializes a new HiResCoord using the values
096: * provided in the argument.
097: * The HiResCoord represents 768 bits of floating point 3-Space.
098: * @param X an eight element array specifying the x position
099: * @param Y an eight element array specifying the y position
100: * @param Z an eight element array specifying the z position
101: */
102: public HiResCoord(int[] X, int[] Y, int[] Z) {
103: int i;
104:
105: this .x = new int[8];
106: this .y = new int[8];
107: this .z = new int[8];
108:
109: for (i = 0; i < 8; i++) {
110: this .x[i] = X[i];
111: this .y[i] = Y[i];
112: this .z[i] = Z[i];
113: }
114:
115: }
116:
117: /**
118: * Constructs and initializes a new HiResCoord using the values
119: * provided in the argument.
120: * The HiResCoord represents 768 bits of floating point 3-Space.
121: * @param hc the HiResCoord to copy
122: */
123: public HiResCoord(HiResCoord hc) {
124: this .x = new int[8];
125: this .y = new int[8];
126: this .z = new int[8];
127:
128: this .x[0] = hc.x[0];
129: this .y[0] = hc.y[0];
130: this .z[0] = hc.z[0];
131:
132: this .x[1] = hc.x[1];
133: this .y[1] = hc.y[1];
134: this .z[1] = hc.z[1];
135:
136: this .x[2] = hc.x[2];
137: this .y[2] = hc.y[2];
138: this .z[2] = hc.z[2];
139:
140: this .x[3] = hc.x[3];
141: this .y[3] = hc.y[3];
142: this .z[3] = hc.z[3];
143:
144: this .x[4] = hc.x[4];
145: this .y[4] = hc.y[4];
146: this .z[4] = hc.z[4];
147:
148: this .x[5] = hc.x[5];
149: this .y[5] = hc.y[5];
150: this .z[5] = hc.z[5];
151:
152: this .x[6] = hc.x[6];
153: this .y[6] = hc.y[6];
154: this .z[6] = hc.z[6];
155:
156: this .x[7] = hc.x[7];
157: this .y[7] = hc.y[7];
158: this .z[7] = hc.z[7];
159: }
160:
161: /**
162: * Constructs and initializes a new HiResCoord located at (0, 0, 0).
163: * The HiResCoord represents 768 bits of floating point 3-Space.
164: */
165: public HiResCoord() {
166: this .x = new int[8];
167: this .y = new int[8];
168: this .z = new int[8];
169: }
170:
171: /**
172: * Sets this HiResCoord to the location specified by the
173: * parameters provided.
174: * @param X an eight-element array specifying the x position
175: * @param Y an eight-element array specifying the y position
176: * @param Z an eight-element array specifying the z position
177: */
178: public void setHiResCoord(int[] X, int[] Y, int[] Z) {
179: int i;
180:
181: for (i = 0; i < 8; i++) {
182: this .x[i] = X[i];
183: this .y[i] = Y[i];
184: this .z[i] = Z[i];
185: }
186:
187: }
188:
189: /**
190: * Sets this HiResCoord to the location specified by the
191: * hires provided.
192: * @param hires the hires coordinate to copy
193: */
194: public void setHiResCoord(HiResCoord hires) {
195: this .x[0] = hires.x[0];
196: this .y[0] = hires.y[0];
197: this .z[0] = hires.z[0];
198:
199: this .x[1] = hires.x[1];
200: this .y[1] = hires.y[1];
201: this .z[1] = hires.z[1];
202:
203: this .x[2] = hires.x[2];
204: this .y[2] = hires.y[2];
205: this .z[2] = hires.z[2];
206:
207: this .x[3] = hires.x[3];
208: this .y[3] = hires.y[3];
209: this .z[3] = hires.z[3];
210:
211: this .x[4] = hires.x[4];
212: this .y[4] = hires.y[4];
213: this .z[4] = hires.z[4];
214:
215: this .x[5] = hires.x[5];
216: this .y[5] = hires.y[5];
217: this .z[5] = hires.z[5];
218:
219: this .x[6] = hires.x[6];
220: this .y[6] = hires.y[6];
221: this .z[6] = hires.z[6];
222:
223: this .x[7] = hires.x[7];
224: this .y[7] = hires.y[7];
225: this .z[7] = hires.z[7];
226: }
227:
228: /**
229: * Sets this HiResCoord's X value to that specified by the argument.
230: * @param X an eight-element array specifying the x position
231: */
232: public void setHiResCoordX(int[] X) {
233: this .x[0] = X[0];
234: this .x[1] = X[1];
235: this .x[2] = X[2];
236: this .x[3] = X[3];
237: this .x[4] = X[4];
238: this .x[5] = X[5];
239: this .x[6] = X[6];
240: this .x[7] = X[7];
241: }
242:
243: /**
244: * Sets this HiResCoord's Y value to that specified by the argument.
245: * @param Y an eight-element array specifying the y position
246: */
247: public void setHiResCoordY(int[] Y) {
248: this .y[0] = Y[0];
249: this .y[1] = Y[1];
250: this .y[2] = Y[2];
251: this .y[3] = Y[3];
252: this .y[4] = Y[4];
253: this .y[5] = Y[5];
254: this .y[6] = Y[6];
255: this .y[7] = Y[7];
256: }
257:
258: /**
259: * Sets this HiResCoord's Z value to that specified by the argument.
260: * @param Z an eight-element array specifying the z position
261: */
262: public void setHiResCoordZ(int[] Z) {
263: this .z[0] = Z[0];
264: this .z[1] = Z[1];
265: this .z[2] = Z[2];
266: this .z[3] = Z[3];
267: this .z[4] = Z[4];
268: this .z[5] = Z[5];
269: this .z[6] = Z[6];
270: this .z[7] = Z[7];
271: }
272:
273: /**
274: * Retrieves this HiResCoord's location and saves the coordinates
275: * in the specified arrays. The arrays must be large enough
276: * to hold all of the ints.
277: * @param X an eight element array that will receive the x position
278: * @param Y an eight element array that will receive the y position
279: * @param Z an eight element array that will receive the z position
280: */
281: public void getHiResCoord(int[] X, int[] Y, int[] Z) {
282: X[0] = this .x[0];
283: X[1] = this .x[1];
284: X[2] = this .x[2];
285: X[3] = this .x[3];
286: X[4] = this .x[4];
287: X[5] = this .x[5];
288: X[6] = this .x[6];
289: X[7] = this .x[7];
290:
291: Y[0] = this .y[0];
292: Y[1] = this .y[1];
293: Y[2] = this .y[2];
294: Y[3] = this .y[3];
295: Y[4] = this .y[4];
296: Y[5] = this .y[5];
297: Y[6] = this .y[6];
298: Y[7] = this .y[7];
299:
300: Z[0] = this .z[0];
301: Z[1] = this .z[1];
302: Z[2] = this .z[2];
303: Z[3] = this .z[3];
304: Z[4] = this .z[4];
305: Z[5] = this .z[5];
306: Z[6] = this .z[6];
307: Z[7] = this .z[7];
308: }
309:
310: /**
311: * Retrieves this HiResCoord's location and places it into the hires
312: * argument.
313: * @param hc the hires coordinate that will receive this node's location
314: */
315: public void getHiResCoord(HiResCoord hc) {
316: hc.x[0] = this .x[0];
317: hc.x[1] = this .x[1];
318: hc.x[2] = this .x[2];
319: hc.x[3] = this .x[3];
320: hc.x[4] = this .x[4];
321: hc.x[5] = this .x[5];
322: hc.x[6] = this .x[6];
323: hc.x[7] = this .x[7];
324:
325: hc.y[0] = this .y[0];
326: hc.y[1] = this .y[1];
327: hc.y[2] = this .y[2];
328: hc.y[3] = this .y[3];
329: hc.y[4] = this .y[4];
330: hc.y[5] = this .y[5];
331: hc.y[6] = this .y[6];
332: hc.y[7] = this .y[7];
333:
334: hc.z[0] = this .z[0];
335: hc.z[1] = this .z[1];
336: hc.z[2] = this .z[2];
337: hc.z[3] = this .z[3];
338: hc.z[4] = this .z[4];
339: hc.z[5] = this .z[5];
340: hc.z[6] = this .z[6];
341: hc.z[7] = this .z[7];
342: }
343:
344: /**
345: * Retrieves this HiResCoord's X value and stores it in the specified
346: * array. The array must be large enough to hold all of the ints.
347: * @param X an eight-element array that will receive the x position
348: */
349: public void getHiResCoordX(int[] X) {
350: X[0] = this .x[0];
351: X[1] = this .x[1];
352: X[2] = this .x[2];
353: X[3] = this .x[3];
354: X[4] = this .x[4];
355: X[5] = this .x[5];
356: X[6] = this .x[6];
357: X[7] = this .x[7];
358: }
359:
360: /**
361: * Retrieves this HiResCoord's Y value and stores it in the specified
362: * array. The array must be large enough to hold all of the ints.
363: * @param Y an eight-element array that will receive the y position
364: */
365: public void getHiResCoordY(int[] Y) {
366: Y[0] = this .y[0];
367: Y[1] = this .y[1];
368: Y[2] = this .y[2];
369: Y[3] = this .y[3];
370: Y[4] = this .y[4];
371: Y[5] = this .y[5];
372: Y[6] = this .y[6];
373: Y[7] = this .y[7];
374: }
375:
376: /**
377: * Retrieves this HiResCoord's Z value and stores it in the specified
378: * array. The array must be large enough to hold all of the ints.
379: * @param Z an eight-element array that will receive the z position
380: */
381: public void getHiResCoordZ(int[] Z) {
382: Z[0] = this .z[0];
383: Z[1] = this .z[1];
384: Z[2] = this .z[2];
385: Z[3] = this .z[3];
386: Z[4] = this .z[4];
387: Z[5] = this .z[5];
388: Z[6] = this .z[6];
389: Z[7] = this .z[7];
390: }
391:
392: /**
393: * Compares the specified HiResCoord to this HiResCoord.
394: * @param h1 the second HiResCoord
395: * @return true if equal, false if not equal
396: */
397: public boolean equals(HiResCoord h1) {
398: try {
399: return ((this .x[0] == h1.x[0]) && (this .x[1] == h1.x[1])
400: && (this .x[2] == h1.x[2]) && (this .x[3] == h1.x[3])
401: && (this .x[4] == h1.x[4]) && (this .x[5] == h1.x[5])
402: && (this .x[6] == h1.x[6]) && (this .x[7] == h1.x[7])
403: && (this .y[0] == h1.y[0]) && (this .y[1] == h1.y[1])
404: && (this .y[2] == h1.y[2]) && (this .y[3] == h1.y[3])
405: && (this .y[4] == h1.y[4]) && (this .y[5] == h1.y[5])
406: && (this .y[6] == h1.y[6]) && (this .y[7] == h1.y[7])
407: && (this .z[0] == h1.z[0]) && (this .z[1] == h1.z[1])
408: && (this .z[2] == h1.z[2]) && (this .z[3] == h1.z[3])
409: && (this .z[4] == h1.z[4]) && (this .z[5] == h1.z[5])
410: && (this .z[6] == h1.z[6]) && (this .z[7] == h1.z[7]));
411: } catch (NullPointerException e2) {
412: return false;
413: }
414:
415: }
416:
417: /**
418: * Returns true if the Object o1 is of type HiResCoord and all of the
419: * data members of o1 are equal to the corresponding data members in
420: * this HiResCoord.
421: * @param o1 the second HiResCoord
422: * @return true if equal, false if not equal
423: */
424: public boolean equals(Object o1) {
425: try {
426: HiResCoord h1 = (HiResCoord) o1;
427: return ((this .x[0] == h1.x[0]) && (this .x[1] == h1.x[1])
428: && (this .x[2] == h1.x[2]) && (this .x[3] == h1.x[3])
429: && (this .x[4] == h1.x[4]) && (this .x[5] == h1.x[5])
430: && (this .x[6] == h1.x[6]) && (this .x[7] == h1.x[7])
431: && (this .y[0] == h1.y[0]) && (this .y[1] == h1.y[1])
432: && (this .y[2] == h1.y[2]) && (this .y[3] == h1.y[3])
433: && (this .y[4] == h1.y[4]) && (this .y[5] == h1.y[5])
434: && (this .y[6] == h1.y[6]) && (this .y[7] == h1.y[7])
435: && (this .z[0] == h1.z[0]) && (this .z[1] == h1.z[1])
436: && (this .z[2] == h1.z[2]) && (this .z[3] == h1.z[3])
437: && (this .z[4] == h1.z[4]) && (this .z[5] == h1.z[5])
438: && (this .z[6] == h1.z[6]) && (this .z[7] == h1.z[7]));
439: } catch (NullPointerException e2) {
440: return false;
441: } catch (ClassCastException e1) {
442: return false;
443: }
444:
445: }
446:
447: /**
448: * Adds two HiResCoords placing the results into this HiResCoord.
449: * @param h1 the first HiResCoord
450: * @param h2 the second HiResCoord
451: */
452: public void add(HiResCoord h1, HiResCoord h2) {
453: // needs to handle carry bits
454: // move to long, add, add in carry bit
455:
456: hiResAdd(this , h1, h2);
457:
458: }
459:
460: /**
461: * Subtracts two HiResCoords placing the results into this HiResCoord.
462: * @param h1 the first HiResCoord
463: * @param h2 the second HiResCoord
464: */
465: public void sub(HiResCoord h1, HiResCoord h2) {
466: HiResCoord tmpHc = new HiResCoord();
467:
468: // negate via two's complement then add
469: //
470: hiResNegate(tmpHc, h2);
471: hiResAdd(this , h1, tmpHc);
472:
473: }
474:
475: /**
476: * Negates the specified HiResCoords and places the
477: * results into this HiResCoord.
478: * @param h1 the source HiResCoord
479: */
480: public void negate(HiResCoord h1) {
481:
482: hiResNegate(this , h1);
483:
484: }
485:
486: /**
487: * Negates this HiResCoord
488: */
489: public void negate() {
490:
491: hiResNegate(this , this );
492:
493: }
494:
495: /**
496: * Scales the specified HiResCoords by the specified value and
497: * places the results into this HiResCoord.
498: * @param scale the amount to scale the specified HiResCoord
499: * @param h1 the source HiResCoord
500: */
501: public void scale(int scale, HiResCoord h1) {
502: hiResScale(h1.x, this .x, scale);
503: hiResScale(h1.y, this .y, scale);
504: hiResScale(h1.z, this .z, scale);
505: }
506:
507: /**
508: * Scales this HiResCoord by the specified value.
509: * @param scale the amount to scale the specified HiResCoord
510: */
511: public void scale(int scale) {
512: hiResScale(this .x, this .x, scale);
513: hiResScale(this .y, this .y, scale);
514: hiResScale(this .z, this .z, scale);
515: return;
516: }
517:
518: /**
519: * Subtracts the specified HiResCoord from this HiResCoord
520: * placing the difference vector into the specified
521: * double-precision vector.
522: * @param h1 the HiResCoord to be subtracted from this
523: * @param v the vector that will receive the result
524: */
525: public void difference(HiResCoord h1, Vector3d v) {
526: // negate coord via two compliment, add, convert result to double
527: // by scaling each bit set appropriately
528:
529: hiResDiff(this , h1, v);
530: return;
531: }
532:
533: /**
534: * The floating point distance between the specified
535: * HiResCoord and this HiResCoord.
536: * @param h1 the second HiResCoord
537: */
538: public double distance(HiResCoord h1) {
539: Vector3d diff = new Vector3d();
540:
541: hiResDiff(this , h1, diff);
542:
543: return (Math.sqrt(diff.x * diff.x + diff.y * diff.y + diff.z
544: * diff.z));
545: }
546:
547: private void hiResNegate(HiResCoord ho, HiResCoord hi) {
548:
549: negateCoord(ho.x, hi.x);
550: negateCoord(ho.y, hi.y);
551: negateCoord(ho.z, hi.z);
552:
553: return;
554: }
555:
556: private void negateCoord(int cout[], int cin[]) {
557: int i;
558:
559: for (i = 0; i < 8; i++) {
560: cout[i] = ~cin[i]; // take compliment of each
561: }
562:
563: for (i = 7; i >= 0; i--) { // add one
564: if (cout[i] == 0xffffffff) {
565: cout[i] = 0;
566: } else {
567: cout[i] += 1;
568: break;
569: }
570: }
571: return;
572: }
573:
574: private void hiResAdd(HiResCoord ho, HiResCoord h1, HiResCoord h2) {
575: int i;
576: long tmp1, tmp2, carry;
577: long signMask = Integer.MAX_VALUE;
578: long signBit = 1;
579: signBit = signBit << 31;
580: long carryMask = 0x7fffffff;
581: carryMask = carryMask << 1;
582: carryMask += 1;
583:
584: carry = 0;
585: for (i = 7; i > 0; i--) {
586: tmp1 = 0;
587: tmp1 = signMask & h1.x[i]; // mask off sign bit so will not get put in msb
588: if (h1.x[i] < 0)
589: tmp1 |= signBit; // add sign bit back
590:
591: tmp2 = 0;
592: tmp2 = signMask & h2.x[i]; // mask off sign bit so will not get put in msb
593: if (h2.x[i] < 0)
594: tmp2 |= signBit; // add sign bit back
595:
596: tmp2 = tmp2 + tmp1 + carry;
597: carry = tmp2 >> 32; // get carry bits for next operation
598: ho.x[i] = (int) (tmp2 & carryMask); // mask off high bits
599: }
600: ho.x[0] = h1.x[0] + h2.x[0] + (int) carry;
601:
602: carry = 0;
603: for (i = 7; i > 0; i--) {
604: tmp1 = 0;
605: tmp1 = signMask & h1.y[i]; // mask off sign bit so will not get put in msb
606: if (h1.y[i] < 0)
607: tmp1 |= signBit; // add sign bit back
608:
609: tmp2 = 0;
610: tmp2 = signMask & h2.y[i]; // mask off sign bit so will not get put in msb
611: if (h2.y[i] < 0)
612: tmp2 |= signBit; // add sign bit back
613:
614: tmp2 = tmp2 + tmp1 + carry;
615: carry = tmp2 >> 32; // get carry bits for next operation
616: ho.y[i] = (int) (tmp2 & carryMask); // mask off high bits
617: }
618: ho.y[0] = h1.y[0] + h2.y[0] + (int) carry;
619:
620: carry = 0;
621: for (i = 7; i > 0; i--) {
622: tmp1 = 0;
623: tmp1 = signMask & h1.z[i]; // mask off sign bit so will not get put in msb
624: if (h1.z[i] < 0)
625: tmp1 |= signBit; // add sign bit back
626:
627: tmp2 = 0;
628: tmp2 = signMask & h2.z[i]; // mask off sign bit so will not get put in msb
629: if (h2.z[i] < 0)
630: tmp2 |= signBit; // add sign bit back
631:
632: tmp2 = tmp2 + tmp1 + carry;
633: carry = tmp2 >> 32; // get carry bits for next operation
634: ho.z[i] = (int) (tmp2 & carryMask); // mask off high bits
635: }
636: ho.z[0] = h1.z[0] + h2.z[0] + (int) carry;
637: return;
638: }
639:
640: private void hiResScale(int tin[], int tout[], double scale) {
641: int i;
642: long tmp, carry;
643: int signMask = Integer.MAX_VALUE;
644: long carryMask = 0x7fffffff;
645: carryMask = carryMask << 1;
646: carryMask += 1;
647: long signBit = 1;
648: signBit = signBit << 31;
649:
650: carry = 0;
651: for (i = 7; i > 0; i--) {
652: tmp = 0;
653: tmp = (long) (signMask & tin[i]); // mask off sign bit
654: if (tin[i] < 0)
655: tmp |= signBit; // add sign bit back
656: tmp = (long) (tmp * scale + carry);
657: carry = tmp >> 32; // get carry bits for next operation
658: tout[i] = (int) (tmp & carryMask); // mask off high bits
659: }
660: tout[0] = (int) (tin[0] * scale + carry);
661: return;
662: }
663:
664: private void hiResDiff(HiResCoord h1, HiResCoord h2, Vector3d diff) {
665: int i;
666: HiResCoord diffHi = new HiResCoord();
667: long value;
668: int coordSpace[] = new int[8];
669: int[] tempCoord;
670: int signMask = Integer.MAX_VALUE;
671: long signBit = 1;
672: signBit = signBit << 31;
673:
674: // negate via two's complement then add
675: //
676: hiResNegate(diffHi, h2);
677: hiResAdd(diffHi, h1, diffHi);
678:
679: if (diffHi.x[0] < 0) {
680: tempCoord = coordSpace;
681: negateCoord(tempCoord, diffHi.x);
682: } else {
683: tempCoord = diffHi.x;
684: }
685: diff.x = 0;
686: for (i = 7; i > 0; i--) {
687: value = (long) (tempCoord[i] & signMask);
688: if (tempCoord[i] < 0)
689: value |= signBit;
690: diff.x += (double) (scales[i] * value);
691: }
692: diff.x += scales[0] * tempCoord[0];
693: if (diffHi.x[0] < 0)
694: diff.x = -diff.x;
695:
696: if (diffHi.y[0] < 0) {
697: tempCoord = coordSpace;
698: negateCoord(tempCoord, diffHi.y);
699: } else {
700: tempCoord = diffHi.y;
701: }
702: diff.y = 0;
703: for (i = 7; i > 0; i--) {
704: value = (long) (tempCoord[i] & signMask);
705: if (tempCoord[i] < 0)
706: value |= signBit;
707: diff.y += scales[i] * value;
708: }
709: diff.y += scales[0] * tempCoord[0];
710: if (diffHi.y[0] < 0)
711: diff.y = -diff.y;
712:
713: if (diffHi.z[0] < 0) {
714: tempCoord = coordSpace;
715: negateCoord(tempCoord, diffHi.z);
716: } else {
717: tempCoord = diffHi.z;
718: }
719: diff.z = 0;
720: for (i = 7; i > 0; i--) {
721: value = (long) (tempCoord[i] & signMask);
722: if (tempCoord[i] < 0)
723: value |= signBit;
724: diff.z += scales[i] * value;
725: }
726: diff.z += scales[0] * tempCoord[0];
727: if (diffHi.z[0] < 0)
728: diff.z = -diff.z;
729: return;
730: }
731: }
|