I
I
i_v2015-07-24 18:43:01
Bots
i_v, 2015-07-24 18:43:01

How to determine the intersection of a segment and a polygon?

Please advise a fast algorithm for finding the fact of intersection of a segment defined by 2 points and a polygon (rotated rectangle). Intersection coordinates are not needed.
fecd15a5caed4e25972f88ce2726b949.pngclarification:
In fact, the task is to filter out segments that do not fall on the monitor screen. The layer on which the segments lie can be rotated. The segments' coordinates are given in the coordinate system of the rotated layer.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Artem Garashko, 2019-09-15
@ArtemG

Try our https://app.metabot24.com - professional chatbot development tool.
With the help of Metabot, you can make a complex bot with a structured menu and artificial intelligence (Dialogflow). There is a scripting language, integrations, mini-CRM with custom tables, mailing lists and much more.
Integration with Instagram is carried out through ready-made integrations with Umnico, Bitrix24 or Jivo.
After registration, a free plan for 100 unique users per month is activated.

T
TinaPolia, 2021-09-15
@TinaPolia

Since the beginning of summer 2021, official chatbots on Instagram have become available. Now there is no need to use gray solutions, and you can build chat bots without the risk of blocking. Sendpulse is convenient for this https://sendpulse.com/ru/features/chatbot/instagram , you can make a welcome menu, respond with prepared phrases for keywords, send messages when mentioned in stories.

A
Artyom11533, 2019-08-05
@Artyom11533

There is talker24.com - a business card with a chatbot, works directly in the Instagram browser

S
Sergey, 2015-07-24
@begemot_sun

It seems to me that you need to switch to the coordinate system of the rectangle, and then just study the special cases of finding a segment outside and in the rectangle

M
Mrrl, 2015-07-25
@Mrl

First, it is better to switch to a coordinate system in which the sides of the rectangle are parallel to the coordinate axes, and the center is at the point (0,0): let the transformation (x,y) -> (p*x+q*y+r,-q* x+p*y+s) the rectangle goes to abs(X) <= A, abs(Y) <= B.
Let (X1,Y1) and (X2,Y2) be the coordinates of the segment vertices after the transformation.
If max(X1,X2) < -A || min(X1,X2) > A || max(Y1,Y2) < -B || min(Y1,Y2) > B, then it does not intersect: the segment is behind one of the sides of the rectangle.
Otherwise, the intersection condition, as far as I understand, will be
abs(X1*Y2-Y1*X2) <= abs(A*(Y2-Y1)) + abs(B*(X2-X1))
Didn't check carefully, but chances are that the formula is correct, good.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question