1. #1

    Find grid points along the edge of a circle?

    Posting this in Evo & Fusion.
    I need an equation to move the rotational point around as if it were someplace else. :huh: It takes a while to explain to all those I have asked so far..



    Imagine you have a map overlay of the current dungeon, with a top-down view of your character seen through it. If you've played Duke Nukem 3D, it would look like that. I would like to give the player the option to freely move the map around, without moving the player, but with the player still visible behind it, (like peripheral vision while checking the map).

    Because the player is stationary, and visible, the map's rotation point should always be where the player is. The issue however is that when I try to rotate the room, it will always rotate around its pivot point rather than around the player. So if the room is moved 2 units along both X and Z, it's pivot point will also be moved there. When it rotates, the player will appear to slide around in a circle, through walls and the rest of the map, making plotting a path very difficult.

    I need an equation to draw a circle around the player, with a diameter length equal to the distance between the map's pivot and the player, then move the map around that circle's edge; (I will spin it with OPE no problems there).

    I have located an equation called "Midpoint Circle Algorithm",
    http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
    but to me right now it looks like potatoes :/.
    Share this post

  2. #2
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195
    Hi, if im understanding you correctly this may help

    place a dummy object at your glue pivot location, not glued to it.
    Ang = Player Yaw

    Rx = dummy object X minus the players position X
    Rz = dummy object Z minus the players position Z

    Tx = Rx * Cos(Ang) + Rz * Sin(Ang) + Player X
    Tz = Rx * - Sin(Ang) + Rz * Cos(Ang) + Player Z

    OPE
    Global Movement
    X= Tx
    Z=Tz
    Rotation (your pivot needs to be globally aligned), not local and set rotation checked.
    Yaw = - Ang

    hope this helps.

    Edit: i got it fixed, i think the vector operators are a little buggy so i resorted to two input and N input operators!

    onedrive video
    Share this post

  3. #3
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195
    hi jolan, i've done a video but cant upload it for some reason, its optimised and i have changed its reference focus so instead of adding the player position it adds the dummy object position, making the dummy object the fixed rotation on the screen (where you map player would be) and changed to a relative player position, its location in the map.

    if you want grid squares divide the Txz by the grid size and floor the value.

    edit:
    I'll knock up a quick doc showing this, and if i can get it uploaded i will.
    Share this post

  4. #4
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195
    Google doc, i think you require the player offset like before

    still not sure exactly what you're looking for, but from what you i believe you want, player is in a room (map) and you want to find the points around them whilst the map and its offset is rotating, but as you map pivot is its rotation point you want to move the center of rotation with math, and thats what my 1st post does.

    ignore player in the 1st post, you have 2 objects that control A) the rotation point and B) the relative position in the map

    this video shows what happens when you swap the two reference objects
    Share this post

  5. #5
    Yes, I believe that first video is precisely what I need . Now I'll have to find a way to put your name in the map
    Share this post

  6. #6
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195
    cool, i understanding much meanings :P and please don't worry about adding my tag to your game, im more than happy to help

    if your interested the formula is based on a simple rotation matrix, wiki

    and oh cool just spotted 'Rotation matrix from axis and angle' in the page.
    Share this post