# should I use slope or another metho

Hi,

I am making a racing game, but need to make the road in it, i’d like to make the road easy to change in case I wanted to change the track from a cirlce to like say and 8. So, I have a function that will loop through all the coordinates of each vertex of the track and then draw each segment. However, since I only have 2 coordinates to each segment of track, I believe my function should calculate the slope and find the perpindicular line to find the vertices to use to create the actual track instead of a line. Im not sure if this would be the best method, I’m a wiz at math so I could figure it out Im just known for taking the hard way to do things. If this is the way I should do it let me know, if not could you point me in the right direction?

P.S. I do kno I’ll have to check for a division by zero.

any and all replies are appreciated

Slope doesn’t work for ‘vertical’ lines. Better is the difference vector between adjacent road segment midpoints and its normalized perpendicular. What you need additionally are the angle bisectors for the perpendiculars in order to generate nice-looking segment corners.

And division by zero is mostly irrelevant, unless your segments have 0 length.