Text Position and Matrix

Corel Paint Shop Pro

Moderator: Kathy_9

Post Reply
bwernick
Posts: 11
Joined: Wed Feb 22, 2012 10:59 pm
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Text Position and Matrix

Post by bwernick »

Hi Folks

I'm stuck on my problem subject again - Vector and Text processing, hope you can help.

This part is logical. Add text to a vector layer and write a script to show the text and the position. From what I can tell, the Characters key is the text and the Start key is the (X,Y) position.

So far no problem, click the text 1 pixel right and the Start[0] increases by 1. Same with 1 pixel down and Start[1] increases by 1.

Now for the crunch... Rotate the text and Start does not change (no matter how much you move the text).

By trial and error, I find that the Matrix key changes.

Now, Matrix has 9 values and from what I can tell Matrix[0], Matrix[1], Matrix[3] and Matrix[4] somehow relate to angle. Probably sin and cos of the angle from the x- and y- axis respectively.

Matrix [2] and Matrix[5] do increase linearly with shifts in x and y but here's where I need help.
How does this relate to the actual position of the text :?:

You can see a more detailed description of the problem and my sample script here.
http://dl.dropbox.com/u/18869118/Articl ... /index.htm


Cheers
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Text Position and Matrix

Post by LeviFiction »

Ugh, math. I'm terrible at math.

Closest thing I can think of, since it never uses more than 9 points and these points represent all of the changes that text can undergo (e.g. rotation, perspective distortion, shear, skew, free transforms, scale) would be Affine transformations. Most other transform matricies usually only use 4 values.

Hopefully a better more informed person will come along. But just in case they don't, that might be something to look into. Again I'm terrible at math, I barely passed college algebra. This could also be a wild goose chase since the information came from me. XD
https://levifiction.wordpress.com/
bwernick
Posts: 11
Joined: Wed Feb 22, 2012 10:59 pm
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Text Position and Matrix

Post by bwernick »

I think computer graphics can be much more confusing than real math.
LeviFiction wrote:... would be Affine transformations...
Thanks, I have never heard of this before. This wiki page seems to confirm what I found by trial and error.
http://en.wikipedia.org/wiki/Transforma ... formations

The problem is, the actual X,Y position does not agree with
x' = x + tx and y' = y + ty

It's probably some small glitch but you have put me on the right track.
bwernick
Posts: 11
Joined: Wed Feb 22, 2012 10:59 pm
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Text Position and Matrix

Post by bwernick »

OK, I think I have found the solution

# Affine Transformation (from wiki)
# xn cos a -sin a tx x
# yn = sin a cos a ty y
# 1 0 0 1 1

# multiplying it out gives
# xn = x cos a - y sin a + tx
# yn = x sin a + y cos a + ty

# Paint Shop Pro gives the sin and cos values with signs
# so you just need to add it up.
xn = x*M[0] + y*M[1] + M[2]
yn = x*M[3] + y*M[4] + M[5]

print xn, yn


Thanks for the help...


Afterthought: I forgot about the angle.
It seems that any of the Matrix angle items can be used to extract the angle. I used M[3] as follows to get the angle in degrees.
angle = 180.0*asin(M[3])/pi


I know there are some things I have not covered. For example, you can stretch, twist and skew the text and I'm not sure where these transform are stored.
Post Reply