The_Dogg Posted January 18, 2007 Share Posted January 18, 2007 Hi, I'm not an expert at PHP, but I'm trying ;Dhere is what I'm trying to do:I have an image (which is a map of some sort) that is, let's say 500px X 800px, and I have to show on that map the location of certain elements, which the coordinates comes from a MySQL DB in the form (x= -115020 y= 32641).The problem is that the coords I get from the DB are higher than the actual image size.What I'm looking for is a way to define a matrix that would go from ie: X= -150000 Y= -75000 to X= 150000 Y= 75000 (with X=0 and Y=0 as the center of the image) so I can use the DB's coords to overlay an image on the exact location.I'm using GD to overlay the image, i just need a way to define those coords on the image.Thank you,The_Dogg Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/ Share on other sites More sharing options...
hvle Posted January 18, 2007 Share Posted January 18, 2007 Do you want to locate the pixel on the image which belong to the coor? Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/#findComment-163773 Share on other sites More sharing options...
The_Dogg Posted January 18, 2007 Author Share Posted January 18, 2007 I think yes, I'll need that pixel so I can add a red X to the image on the right spot.but maybe I mis-understood your question, if so then I'm sorry. Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/#findComment-163849 Share on other sites More sharing options...
The_Dogg Posted January 19, 2007 Author Share Posted January 19, 2007 anyone can point me in the right direction? Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/#findComment-164426 Share on other sites More sharing options...
hvle Posted January 19, 2007 Share Posted January 19, 2007 hey dogg,I will show you a simple to map the coor to a pixel on image. This is an example on the horizonal x coordinate only. y coordinate is similar.[code]// provide that the width of your image is 500px;$xi_min = 0; // the starting pixel of your image $xi_max = 500; // the end pixel of your image// assume that the x-coordiate go from 1000 to 2000$xcoor_min = 1000;$xcoor_max = 2000;//assume that I have a coordiate which has x-coor is 1500; $myX = 1500;$result = ($myX - $xcoor_min) / ($xcoor_max - $xcoor_min);$result = (($xi_max - $xi_min) * $result) + $xi_min;echo $result;[/code]this code above will echo 250;explain: myX is 1500 while the coor ranged from 1000 to 2000, this result in the coor falling exactly half way on the image.and there you go, the result is 250, which is half way on the image.for y-coordinate, it is similar. Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/#findComment-164744 Share on other sites More sharing options...
The_Dogg Posted January 21, 2007 Author Share Posted January 21, 2007 this is awesome, this is exactly what I was looking for. Thanks a lot man, this is greatly appreciated.good job! Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/#findComment-165852 Share on other sites More sharing options...
hvle Posted January 22, 2007 Share Posted January 22, 2007 You're welcome. Link to comment https://forums.phpfreaks.com/topic/34748-define-a-matrix-over-an-image/#findComment-166642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.