A
A
Alexey Lebedev2016-05-31 12:17:35
Algorithms
Alexey Lebedev, 2016-05-31 12:17:35

What is the best way to store data for a point on a plane?

There is a way - an array of points on the plane.
There are walls. It is necessary to check that the waypoints do not cross the walls.
Walls are dots.
(x, y)
What is the best way to store wall points?

Dictionary<string, bool> wall = 
            new Dictionary<string, bool>();
            wall['1_1']=true;
        if (!wall.ContainsKey("1_1"))
        {
            // стена !!
        }

Well, do you have any better ideas?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2016-05-31
@xmoonlight

The path is the stack.
Walls are dots?! Maybe segments connected by dots?!
Walls=segments - it is better to store in the structural array "walls": x0,y0 and x1,y1 (coordinates of the beginning and end of the segment)
In order not to intersect - the formula for the intersection of two lines from geometry.

G
GreatRash, 2016-05-31
@GreatRash

Store everything in vectors. In principle, a point is a vector with zero length (mathematicians will beat me, and the dog is with them). Well, then look for intersections :)

A
abcd0x00, 2016-06-01
@abcd0x00

There are walls. It is necessary to check that the waypoints do not cross the walls.

You have a path - it's a broken line, which consists of segments, which consist of points.
You have a wall - it's a broken line, which consists of segments, which consist of points.
(0, 1) is one point
{(0, 1), (2, 3)} is one segment
{{(0, 1), (2, 3)}, {(2, 3), (4 , 5)}, {(4, 5), (6, 7)}} - this is one polyline
Keep it that way: you need to do this with the point class, the segment class and the polyline class.
To determine whether a path intersects a wall, you need to determine whether the path segments intersect with wall segments.
The polyline class must have a method that checks the intersection of a polyline with another polyline.
The segment class must have a method that checks the intersection of a segment with another segment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question