0

I have a project where I am making a random terrain and then just moving a bike along it. the terrain generates random displacement points and makes a 2d map of mountains, etc.

I have an array of points and what i want to do is make my bike image to either rotate or be able to be placed or aligned were the two wheels are equal to the two y points that they are supposed to be.

For example if the bike is at x=10 middle of bike and the wheels are 2 to the right and left i want to position the bike to align with the x=8 and x=12 and corresponding y points from my terrain array.

I've looked around so hard and have found nothing that will work. all help will be appreciated thank you very much.

p.s. if u need script of any part of my project just ask im using a raspberry pi so i will just get it off it.

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
  • doesn't that mean the bike frame will stretch? What if `x+2` is 10 meters taller than `x-2`? – Adam Smith Jun 02 '15 at 23:02
  • i understand that, right now i just dont care cause i rather it work and look aright over not work at all. saying that i would prefer a rotation and any help would be amazing however to rotate i need to rotate on the botom of image between wheel and python only reference from left top conner or center as far as i know – EliteSkull Jun 02 '15 at 23:09
  • though the stretching would not be that bad as the terrain does not have that steap of a hill it desined to only move up or down between 2 and 0 pixels for every 1 pixel so since bike is so smal that should never happen – EliteSkull Jun 02 '15 at 23:11
  • I respectfully [disagree](https://gist.github.com/NotTheEconomist/28c23c2cc1943b49190b) – Adam Smith Jun 02 '15 at 23:16
  • fair enough, what is your opinion on what I should do? – EliteSkull Jun 02 '15 at 23:21
  • Don't think about how long the line has to be to go from A->B, think about what angle a line of length 4 would be if it hinged on point A and touched the ground at point B. Trigonometry! – Adam Smith Jun 02 '15 at 23:29
  • Yes I've tried that however rotating in python is horrible and i need to rotate my bike around a point between the wheels if I do that – EliteSkull Jun 02 '15 at 23:39
  • @Adam Beat me to it. I'd find 2 points on the terrain, use some equation to find the angle/slope between them, then translate that into rotation of the bike. If you use slope, the "equation of a line" will be useful. If you want to get fancier, you could use trig as he suggested. If you're just dealing with 2 points, you can always make them into right triangle and go from there. – Carcigenicate Jun 02 '15 at 23:39
  • This question really needs example code. – Marius Jun 03 '15 at 00:54

0 Answers0