Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Quick query, moving from different views

Hi! I have to hand this coursework in tomorrow, slight snag in the mapping part of it. I'm moving from "robot view" to "display view". Basically the robot is drawing a map of the screen based on what it picks up on radar -

pseudocoding it because my Uni uses turn it in:


robot x = get robot's x position
robot y = get robot's y position
robot t = get robot's theta (angle relative to the room)

distance = get sonar distance from sonar at 10 degrees

Get the x and y of the picked up object relative to the robot.
x = cos(10) * distance
y = sin(10) * distance

Relative to the bot, there is an object at (x,y)
Convert to the display coordinate system


display x = (cos(-t) * x) - (sin(-t) * y)
display y = (sin(-t) * x) + (cos(-t) * y)

Basically have rotated it around (0,0) -t degrees

Translate based on the robot's position

display x -= robot x
display y -= robot y

add point to map: (display x, display y)



____________________________________
My question is simply: is the above correct? Should it work?

It's not working, I'm getting garbage, but I need to acertain whether it's my coding or the robot itself that is broken.

Thanks in advance.
 
Imagine a robot in a room. The robot has an x and y position, relative to the room. It also has a rotation. It happens to spot an object that is 300mm away, at an angle of 10 degrees from the robot.

What I need to do is plot that point relative to the room, not to the robot. Does that make sense?

Yes this is coursework.
 
It turns out my calculations are (probably) correct, and that it's the robot that's broken. It is reporting back completely wrong values for X, Y, T.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top