A
A
Amir Gafurov2015-09-21 14:38:18
JavaScript
Amir Gafurov, 2015-09-21 14:38:18

How to determine if 8 points are a square?

794af0e92b864eb9ae8bb848af0b92f8.png
There are coordinates (i, j) 8 points (red), how to determine that this set is a square ?
And also how to calculate the coordinate of the blue point if this set is still a square?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lyeskin, 2015-09-21
@lyeskin

A quick thought gave such an option - we have points in the format (x, y), we select the plane along which we will group the planes, for example y.
Grouping points:

{
    y1 : [ y1x1, y1x2, y1x3],
    y2 : [ y2x1, y2x2],
    y3 : [y3x1, y3x2, y3x3]
}

In your case it will be
{
    2 : [2, 3, 4],
    3 : [2, 4],
    4 : [2, 3, 4]
}

Now there are the following rules - the minimum and maximum element in the array must be equal to y1 and y3 respectively: i.e. in each array (at index 2, 3 and 4) the minimum element will be 2, and the maximum 4. And one more rule - there should be only 3 y-keys (2 by 3 elements and 1 by 2 elements). I think I roughly explained the idea, but I do not pretend to be the right solution

D
Dmitry Kovalsky, 2015-09-21
@dmitryKovalskiy

I hope you did not skip the school geometry course and know how to calculate the scalar product of vectors, as well as calculating the length of segments by coordinates. Calculating the coordinates of the blue point is the task of finding the midpoint of the segment between two opposite points.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question