c# - Find the index in a single array of a Cartesian coordinate -


I'm trying to remove something that should still be very simple, for some reason I could not find the answer . I have been trying sources for the past few hours. Take a 10 to 10 cartridge coordinate system with 10 grams of 10 grid. In each coordinate a float is given (setting the height) and it has been read in the float [] row from the first line (0,0) (10,0) second row (0,1) (10, 1). Now I want to write a certain method, to bring the height of a certain Cartesian coordinate: (10, 0). This float float will be on index 9 in [1] and will be located on (0, 1) 10 index. I have tried many endeavors, but every time (0, 0) is a stubborn mule, here are some sources.

  Z = (Y * 10 + X) works for 0, 0 but not really for 10, because it index 9 z = ((Y * 10 + x) - 1) Works for 10, 0, but not good for 0, 0  

I tried something more complicated, but now I do not remember them since my notepad Can I write them without having stopped saving? I would be happy if someone could keep me in the right direction, but please clarify the simple math explanation. Use.

If your grid is 10 10, then it is (0,0) to (9) . There are 11 items from one row (0,0) to (10,0) in one line, so your function should be:

  Z = (Y * 11 + X)  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -