- Home /

# Convert arbitrary coordinates to texture pixel coordinates

I have data which describes word positions on a page in pt coordinates where 1 pt is 1/72 inch. I need to be able to transform these coordinates into pixel space relative to a texture pixel resolution of 1024 by 1587.

I know that I need to somehow normalise the pt coordinates and then use the resultant ratio to multiply by the texture width / height, but I'm not sure of the calculation to perform the normalisation. I'd be grateful for any suggestions.

**Answer** by ScroodgeM
·
Aug 05, 2012 at 01:21 PM

you need inches-to-pixels scale also known as DPI. without that your task has no solution.

**Answer** by Bunny83
·
Aug 05, 2012 at 05:35 PM

The resolution of your texture is irrelevant when you have a certain DPI. You have a dpi (dots per inch) of 72, so just multiply your inch-value by 72, drop the fractional part and you have pixel coordinates:

```
var DPI = 72.0f;
var coords = new Vector2(2.12f, 3.15f);
coords *= DPI;
coords.x = Mathf.Floor(coords.x);
coords.y = Mathf.Floor(coords.y);
Debug.Log(coords);
```

This will print 152 / 226 which is the pixel coordinate of the given inch-coordinate (2.12 / 3.15)

'pt' is a typographical measure unit, that is 1/72 inch. but pt != pixel AFAIK...

Yes, maybe i got the question wrong. By rereading it looks like he's talking about coordinates in pt (or point), but as you said, without the ratio between the realworld units (pt, inch) and the logical pixel unit it's not possible. It's all a matter of scale.

Thanks for your answers and I had come to a similar conclusions myself - there is no direct relationship between pts and pixels. So I need to know the ratio of the original coordinate system extents (width / height) and the target image extents . I can then use this ratio to calculate pixels coordinates to point coordinates or vice versa. Since the two coordinate systems in the case are proportional - this should not be a problem.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Can I transform all of my objects by referencing 2 points? 0 Answers

Touch point to world coordinate and local coordinate 1 Answer

how can i get objects size according to world coordinate? 1 Answer

Align HTC Vive Coordinate with OptiTrack System in Unity 0 Answers

How can I find an object's height? 2 Answers