ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Frameworks/MiscAppKit/MiscTreeDiagram.subproj/MiscTDUtils.m

This is MiscTDUtils.m in view mode; [Download] [Up]

/*	MiscTDUtils.m

	Copyright 1996 Uwe Hoffmann.

	This notice may not be removed from this source code.
	The use and distribution of this software is governed by the
	terms of the MiscKit license agreement.  Refer to the license
	document included with the MiscKit distribution for the terms.

	Version 2 (August 1996)
*/

#import <Foundation/Foundation.h>

BOOL miscTD_straddles(NSPoint p1, NSPoint p2, NSPoint p3, NSPoint p4)
{
	float crossP1, crossP2;
	
	crossP1 = (p3.x - p1.x) * (p2.y - p1.y) - (p2.x - p1.x) * (p3.y - p1.y); 
	crossP2 = (p4.x - p1.x) * (p2.y - p1.y) - (p2.x - p1.x) * (p4.y - p1.y);
	if((crossP1 > 0 && crossP2 < 0) || (crossP1 < 0 && crossP2 > 0)){
		crossP1 = (p1.x - p3.x) * (p4.y - p3.y) - (p4.x - p3.x) * (p1.y - p3.y); 
		crossP2 = (p2.x - p3.x) * (p4.y - p3.y) - (p4.x - p3.x) * (p2.y - p3.y);
		if((crossP1 > 0 && crossP2 < 0) || (crossP1 < 0 && crossP2 > 0))
			return YES;
		else
			return NO;
	} else
		return NO;
} 

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.