Results 1 to 6 of 6

Math Help - calculations in an unbounded 2D space

  1. #1
    Member
    Joined
    Aug 2011
    Posts
    76
    Thanks
    1

    calculations in an unbounded 2D space

    Greetings, O wise and knowledgable math geniuses. Is there an elegant system for representing a finite, unbounded 2D space and performing the common 2D geometric calculations (distance between points, movement, etc.) on it in a coherent way? I want to code an arcade game played on a 2D space that is finite but wraps around in every direction. In past attempts I just represented space as a bounded box, and I corrected coordinates after every calculation that produced them, but this was rather messy. Is there a better approach?

    My first thought was to somehow map the 2D space over a sphere and translate 2D calculations into 3D calculations around the sphere.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Mar 2011
    From
    Tejas
    Posts
    3,312
    Thanks
    692

    Re: calculations in an unbounded 2D space

    i think you can do this:

    let frac(x) be the fractional part of x (for example if x = 6.25, frac(x) = 0.25). this can also be calculated as x - floor(x).

    assign all your coordinates on your "screen" (world) values between 0 and 1. then define:

    (a,b) + (c,d) = (frac(a+c), frac(b+d)).

    if you want "on-screen" distances, apply frac before you calculate the distance. if you want "off-screen distances" (like you shoot at the right end of the screen, and it hits something on the left side) don't apply frac at all (note: this means two objects can be "multiple distances away from each other"...could get confusing).

    using a map of your "world" to a sphere will identify all 4 corners (and edges) as the same point...what i think you want to do to achieve left/right wrap-around and up/down wrap-around is to map your world to a torus (doughnut). while you could parameterize such a surface in 2 variables like so:

    x = Rcos(s) + rcos(s)cos(t)
    y = Rsin(s) + rsin(s)cos(t)
    z = rsin(t)

    and calculate distance using arc-length, i think the "frac" approach above would be easier to implement (basically, we are identifying neighboring worlds (off-screen) with the one you can see (on-screen)).
    Last edited by Deveno; August 18th 2012 at 06:36 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor

    Joined
    Aug 2006
    Posts
    18,605
    Thanks
    1574
    Awards
    1

    Re: calculations in an unbounded 2D space

    Quote Originally Posted by infraRed View Post
    Is there an elegant system for representing a finite, unbounded 2D space and performing the common 2D geometric calculations (distance between points, movement, etc.) on it in a coherent way? I want to code an arcade game played on a 2D space that is finite but wraps around in every direction.
    When I first read your post, I had no idea what it could mean. After seeing reply #2, I wonder if you are asking about a bounded metric?

    On any metric space, if d(x,y) is the metric then e(x,y)=\frac{d(x,y)}{1+d(x,y)} is also a metric.

    Moreover, it is a bounded metric, i.e. e(x,y)\le 1.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor

    Joined
    Mar 2011
    From
    Tejas
    Posts
    3,312
    Thanks
    692

    Re: calculations in an unbounded 2D space

    Quote Originally Posted by Plato View Post
    When I first read your post, I had no idea what it could mean. After seeing reply #2, I wonder if you are asking about a bounded metric?

    On any metric space, if d(x,y) is the metric then e(x,y)=\frac{d(x,y)}{1+d(x,y)} is also a metric.

    Moreover, it is a bounded metric, i.e. e(x,y)\le 1.
    this is true, but it tends to "compress" the edges. if the OP is doing something like the game asteroids, this wouldn't work...the edges of the screen are "infinity" and you can't ever cross them.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Aug 2011
    Posts
    76
    Thanks
    1

    Re: calculations in an unbounded 2D space

    Quote Originally Posted by Deveno View Post
    this is true, but it tends to "compress" the edges. if the OP is doing something like the game asteroids, this wouldn't work...the edges of the screen are "infinity" and you can't ever cross them.
    Yes, basically like Asteroids -- space wraps around in whichever direction you go -- except that space is larger than just the screen width and height. So, by "unbounded" I meant that one can move infinitely long in one direction in space, but it is finite because this periodically brings you back to your starting point. So if you were passed by a spaceship going faster than you in the same direction, you would eventually see it approaching from the rear.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor

    Joined
    Apr 2005
    Posts
    15,386
    Thanks
    1323

    Re: calculations in an unbounded 2D space

    A "finite unbounded space" would be just the opposite- a finite set of points such that there exist arbitrarily large distances between points. And it seems to me that the only way you could do that would be to have an infinite distance between some of the points.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Question on null space/column space/row space of a matrix
    Posted in the Advanced Algebra Forum
    Replies: 5
    Last Post: December 1st 2011, 01:47 PM
  2. Unbounded functional
    Posted in the Differential Geometry Forum
    Replies: 2
    Last Post: March 29th 2011, 03:07 AM
  3. Unbounded?
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: February 7th 2010, 12:56 PM
  4. Unbounded Operators
    Posted in the Differential Geometry Forum
    Replies: 6
    Last Post: March 22nd 2009, 01:01 PM
  5. Unbounded sequences
    Posted in the Calculus Forum
    Replies: 1
    Last Post: November 25th 2008, 09:07 AM

Search Tags


/mathhelpforum @mathhelpforum