Solved

Help getting a value from coordinates

Posted on 2009-03-30
2
234 Views
Last Modified: 2012-05-06
Hi Folks!

Its a late night for me an I cant figure this out.. my heads numb.

I have the following function that converts x, y values to coordinates value on a grid.
Ie with the grid width & height at 400 with 20 columns and rows the following

The attached functions convert the coordinates to an x,y value ie..

(0,0) =  (x=0, y=0)
(1,1) = (x=20,y=20)
(2,2)=(x=40,y=40)

How can I go about getting the inverse using the parameters gridWidth, gridHeight.... etc

Ie..
if the x value is between 0-20 then the x coord is 0
or between 20-40 the x coord is 1?

regards
Steve
gridWidth = 400;
gridColumns = 20;
gridHeight = 400;
gridRows = 20;
 
public static double coordToX(double coord){
    return (gridWidth / gridColumns) * coord;
}
 
public static double coordToY(double coord){
    return (gridHeight / gridRows) * coord;
}

Open in new window

0
Comment
Question by:Stephen Manderson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 24025257
public static double XTOcoordToX(double X){
    return (gridColumns /  gridWidth) * X;
}
 
public static double YTOcoord(double Y){
    return ( gridRows / gridHeight) * Y;
}
0
 
LVL 19

Author Comment

by:Stephen Manderson
ID: 24025307
Thanks once again ozo! :) Knew it was something very simple lol
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java: The Public Class Main 4 66
ejb mdb examples 1 39
Delphi Firemonkey: if the Sms contain special characters it won't send it 3 82
Java array 10 86
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question