Skip to content

Way to calculate Distance between two Points #131

Description

@fengyuanyang

Description
Give two points(x, y),
need a way to get distances

Given 4 parameters (x1, y1, x2, y2)
When x1 = 0, y1 = 0, x2 = 1, y2 = 0
Expect return 1;

When x1 = 0, y1 = 0, x2 = 0, y2 = 1
Expect return 1;

When x1 = 0, y1 = 0, x2 = 1, y2 = 1
Expect return Math.sqrt(2);

When x1 = 3, y1 = 2, x2 = 7, y2 = 7
Expect return Math.sqrt(41);

When x1 = -3, y1 = -2, x2 = 7, y2 = 7
Expect return Math.sqrt(181);

Additional context

Add any other context, links references or screenshots about the feature request here.

Important Checklist

  • I have written unit test first, make it red(fail first).
  • I have then written logic code, make it green(success)
  • I have tried to refactor my code, make it understandable(document my code)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions