001: /*
002: *
003: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
004: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License version
008: * 2 only, as published by the Free Software Foundation.
009: *
010: * This program is distributed in the hope that it will be useful, but
011: * WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * General Public License version 2 for more details (a copy is
014: * included at /legal/license.txt).
015: *
016: * You should have received a copy of the GNU General Public License
017: * version 2 along with this work; if not, write to the Free Software
018: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022: * Clara, CA 95054 or visit www.sun.com if you need additional
023: * information or have any questions.
024: */
025:
026: package com.sun.pisces;
027:
028: public class Transform6 extends Transform4 {
029: static {
030: PiscesLibrary.load();
031: }
032:
033: public int m02, m12;
034:
035: public Transform6() {
036: this (1 << 16, 0, 0, 1 << 16, 0, 0);
037: }
038:
039: public Transform6(int m00, int m01, int m10, int m11, int m02,
040: int m12) {
041: super (m00, m01, m10, m11);
042:
043: initialize();
044:
045: this .m02 = m02;
046: this .m12 = m12;
047: }
048:
049: public Transform6(Transform6 t) {
050: this (t.m00, t.m01, t.m10, t.m11, t.m02, t.m12);
051: }
052:
053: public void postMultiply(Transform6 t) {
054: long _m00 = ((long) m00 * t.m00 + (long) m01 * t.m10) >> 16;
055: long _m01 = ((long) m00 * t.m01 + (long) m01 * t.m11) >> 16;
056: long _m10 = ((long) m10 * t.m00 + (long) m11 * t.m10) >> 16;
057: long _m11 = ((long) m10 * t.m01 + (long) m11 * t.m11) >> 16;
058: long _m02 = (((long) m02 << 16) + (long) m00 * t.m02 + (long) m01
059: * t.m12) >> 16;
060: long _m12 = (((long) m12 << 16) + (long) m10 * t.m02 + (long) m11
061: * t.m12) >> 16;
062:
063: this .m00 = (int) _m00;
064: this .m01 = (int) _m01;
065: this .m02 = (int) _m02;
066: this .m10 = (int) _m10;
067: this .m11 = (int) _m11;
068: this .m12 = (int) _m12;
069: }
070:
071: public Transform6 inverse() {
072: // long lm00 = (long)m00;
073: // long lm01 = (long)m01;
074: // long lm02 = (long)m02;
075: // long lm10 = (long)m10;
076: // long lm11 = (long)m11;
077: // long lm12 = (long)m12;
078: // long det = lm00*lm11 - lm01*lm10;
079:
080: // int a00 = (int)((lm11 << 32)/det);
081: // int a01 = (int)(-(lm01 << 32)/det);
082: // int a10 = (int)(-(lm10 << 32)/det);
083: // int a11 = (int)((lm00 << 32)/det);
084: // int a02 = (int)(((lm01*lm12 - lm02*lm11) << 8)/det) << 8;
085: // int a12 = (int)(((lm02*lm10 - lm00*lm12) << 8)/det) << 8;
086:
087: float fm00 = m00 / 65536.0f;
088: float fm01 = m01 / 65536.0f;
089: float fm02 = m02 / 65536.0f;
090: float fm10 = m10 / 65536.0f;
091: float fm11 = m11 / 65536.0f;
092: float fm12 = m12 / 65536.0f;
093: float fdet = fm00 * fm11 - fm01 * fm10;
094:
095: float fa00 = fm11 / fdet;
096: float fa01 = -fm01 / fdet;
097: float fa10 = -fm10 / fdet;
098: float fa11 = fm00 / fdet;
099: float fa02 = (fm01 * fm12 - fm02 * fm11) / fdet;
100: float fa12 = (fm02 * fm10 - fm00 * fm12) / fdet;
101:
102: int a00 = (int) (fa00 * 65536.0);
103: int a01 = (int) (fa01 * 65536.0f);
104: int a10 = (int) (fa10 * 65536.0f);
105: int a11 = (int) (fa11 * 65536.0f);
106: int a02 = (int) (fa02 * 65536.0f);
107: int a12 = (int) (fa12 * 65536.0f);
108:
109: return new Transform6(a00, a01, a10, a11, a02, a12);
110: }
111:
112: public boolean isIdentity() {
113: return (m00 == 1 << 16 && m01 == 0 && m10 == 0
114: && m11 == 1 << 16 && m02 == 0 && m12 == 0);
115: }
116:
117: public String toString() {
118: return "Transform6[" + "m00=" + (m00 / 65536.0) + ", " + "m01="
119: + (m01 / 65536.0) + ", " + "m02=" + (m02 / 65536.0)
120: + ", " + "m10=" + (m10 / 65536.0) + ", " + "m11="
121: + (m11 / 65536.0) + ", " + "m12=" + (m12 / 65536.0)
122: + "]";
123: }
124:
125: private native void initialize();
126: }
|