[
https://issues.apache.org/jira/browse/PDFBOX-1960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13923706#comment-13923706
]
Maruan Sahyoun commented on PDFBOX-1960:
----------------------------------------
I don’t agree that the two matrices are „ …. doing the exec same thing …“.
Although both are doing a matrix multiplication (which is the exact same thing)
they do it with a different model and based on a transposed (from each others
point of view) matrix. Because of that - other than doing a matrix
multiplication - they are NOT doing the exact same thing (otherwise you would
get the same results).
PDF has a definition of doing [x’ y’ 1] = [x y 1] x [Tx] (ISO 32000 p 120)
where Affine Transformation has [x’ y’ 1] = [Tx] x [x y 1]
(http://en.wikipedia.org/wiki/Transformation_matrix). A PDF Matrix is
transposed compared to Java’s AffineTransform matrix.
Furthermore „ … PDF transformation matrices specify the conversion from the
transformed coordinate system to the original (untransformed) coordinate system
…“ (ISO 32000 p 120). So although PDF Matrix transformation can be expressed as
Java Affine Transformation they are not directly compatible because of the
different definitions in place.
I do understand that it’s easy to mix it up because of the different
definitions so if Matrix can be enhanced to make it easier to work with Java’s
Affine Transform we should do so. Maybe in a different class as we want to
remove the dependency from awt in the minimum core. But Matrix shall be defined
so it follows the PDF spec and not Java’s Affine Transform.
So again I would propose to add
- JavaDoc to educate users about the differences (at least to point them to the
spec)
- methods to make it easier to interchange between both (if
createAffineTransform() and setFromAffineTransform() are not already sufficient)
At the end one could get the Matrix from PDF, apply all transformations in
Java’s AffineTransform and set the Matrix with the result.
> Matrix and AffineTransform have confusing differences
> -----------------------------------------------------
>
> Key: PDFBOX-1960
> URL: https://issues.apache.org/jira/browse/PDFBOX-1960
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 2.0.0
> Reporter: John Hewson
> Assignee: Maruan Sahyoun
> Priority: Minor
>
> I've been driven insane recently by trying to get pattern fills to render
> correctly. Patterns have their own matrix which is concatenated to the CTM
> and no matter how I applied the transformation, the results were wrong.
> It turns out that org.apache.pdfbox.util.Matrix is not behaving as expected,
> here's an example from a pattern I'm working on. I performed the same
> concatenation (i.e. multiplication) using our Matrix and Java's
> AffineTransform, the results are as follows:
> Java AffineTransform:
> [[2.0, 0.0, 1.251E-12], [0.0, 2.0, 1684.0]] *
> [[0.6, 0.0, 302.6], [0.0, 0.6, 1091.38]] =
> [[1.2, 0.0, 605.2000000000013], [0.0, 1.2, 3866.76]]
> PDFBox Matrix:
> [[2.0,0.0,0.0][0.0,2.0,0.0][1.251E-12,1684.0,1.0]] *
> [[0.6,0.0,0.0][0.0,0.6,0.0][302.6,1091.38,1.0]] =
> [[1.2,0.0,0.0][0.0,1.2,0.0][302.6,2101.78,1.0]]
> I suggest that we remove Matrix and replace it with AffineTransform.
--
This message was sent by Atlassian JIRA
(v6.2#6252)