issameside

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2012-07-13, Last change: 2025-09-14

return whether 2 points p1,p2 are on the same side of a line through A to B

Description

from http://www.blackpawn.com/texts/pointinpoly/default.html


See Also: , isintriangle2

Example Illustration

 missing image of issameside(p1,p2,A,B)

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

b: result




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

Output

Algorithm Steps

  1. Calculate the vector from A to B as B - A.
  2. Calculate the vector from A to p1 as p1 - A.
  3. Calculate the vector from A to p2 as p2 - A.
  4. Compute the cross product of the vector B - A with p1 - A, resulting in cp1.
  5. Compute the cross product of the vector B - A with p2 - A, resulting in cp2.
  6. Check the sign of the dot product of cp1 and cp2:
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