How do you calculate a Vector from a Line Segment?

55 Views Asked by At

I'm following this game development thread: https://gamedev.stackexchange.com/questions/90609/how-can-i-check-if-a-player-drawn-line-follows-a-path to essentially project a bunch of vectors onto some user drawn set of vectors (not sure if that terminology is correct).

Right now I have a series of line segments for both the character I drew: (x1,y1) to (x2,y2) and

character that users drew: (x3,y3) to (x4,y4).

How do I convert each (x1,y1) -> (x2,y2) set of coordinates to vectors? I found some conflicting information and couldn't figure out what the formula was. Right now I'm using a formula like the below

func computeVectorsFromTwoPoints(point1: Point, point2: Point) -> Vector {
    let dx: Float = point2.x - point1.x
    let dy: Float = point2.y - point1.y
    
    return Vector(dx: dx, dy: dy)
}

Any help or direction is appreciated, thank you!

but I think this is calculating distance?