Syntax
b=issameside(p1,p2,A,B)
Input Parameter
p1 : | | point to test |
p2 : | | point to test |
A : | | Point A of line |
B : | | Point B of line |
Output Parameter
Copyright 2012-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This algorithm determines whether two points, p1
and p2
, are on the same side of a line defined by two other points, A
and B
.
Input Parameters
- p1: A point to test, represented as a vector.
- p2: Another point to test, represented as a vector.
- A: The first point defining the line, represented as a vector.
- B: The second point defining the line, represented as a vector.
Output
- b: A boolean result indicating whether
p1
and p2
are on the same side of the line through A
and B
.
Algorithm Steps
- Calculate the vector from
A
to B
as B - A
.
- Calculate the vector from
A
to p1
as p1 - A
.
- Calculate the vector from
A
to p2
as p2 - A
.
- Compute the cross product of the vector
B - A
with p1 - A
, resulting in cp1
.
- Compute the cross product of the vector
B - A
with p2 - A
, resulting in cp2
.
- Check the sign of the dot product of
cp1
and cp2
:
- If the dot product is greater than or equal to zero, set
b
to true
, indicating that p1
and p2
are on the same side of the line.
- If the dot product is less than zero, set
b
to false
, indicating that p1
and p2
are on opposite sides of the line.
Algorithm explaination created using ChatGPT on 2025-08-18 22:46. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21