[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FW: [Fwd: Bug in NSAffineTransform]
From: |
Fred Kiefer |
Subject: |
Re: FW: [Fwd: Bug in NSAffineTransform] |
Date: |
Mon, 27 Feb 2006 16:56:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 |
Adam Fedor wrote:
> On 2006-02-23 13:11:00 -0700 "Vaisburd, Haim" <HVaisbur@Advent.COM> wrote:
>>
>> The matrix multiplication is not commutative and the last line should be
>> instead
>> matrix = matrix_multiply(matrix, tranm);
>>
>
> Do you have a test that shows this is wrong? All my tests work with the
> current version (as well as give the same result as Mac OSX).
>
>
>> I prefer the old version though:
>>
>> - (void) translateXBy: (float)tranX yBy: (float)tranY
>> {
>> TX += tranX;
>> TY += tranY;
>> }
>>
>> it's clearer and faster.
>
> But incorrect. Remember we are translating a coordinate system, not a
> point.
>
I did write a small test application to find out, what is the correct
behaviour, as I never can tell, where append and where prepend should be
used. The following code should be run on MacOSX and the result be
compared with the one on GNUstep:
void test_translate()
{
NSAffineTransform *base;
NSAffineTransform *res;
NSAffineTransform *trans;
NSAffineTransformStruct struc = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
base = [[NSAffineTransform alloc] init];
[base setTransformStruct: struc];
trans = [[NSAffineTransform alloc] init];
[trans translateXBy: 10.0 yBy: 20.0];
res = [base copy];
[res appendTransform: trans];
NSLog(@"Append %@", res);
RELEASE(res);
res = [base copy];
[res prependTransform: trans];
NSLog(@"Prepend %@", res);
RELEASE(res);
res = [base copy];
[res translateXBy: 10.0 yBy: 20.0];
NSLog(@"Translate %@", res);
RELEASE(res);
}
int main (int argc, const char *argv[])
{
CREATE_AUTORELEASE_POOL(pool);
test_translate();
RELEASE(pool);
return 0;
}
For me the GNUstep result is:
2006-02-27 16:52:59.048 affine[14464] Append NSAffineTransform
((1.000000, 2.000000) (3.000000, 4.000000) (15.000000, 26.000000))
2006-02-27 16:52:59.053 affine[14464] Prepend NSAffineTransform
((1.000000, 2.000000) (3.000000, 4.000000) (75.000000, 106.000000))
2006-02-27 16:52:59.053 affine[14464] Translate NSAffineTransform
((1.000000, 2.000000) (3.000000, 4.000000) (75.000000, 106.000000))
Showing that translate uses a prepend on GNUstep. Now we need to know
how it looks on Cocoa.