//----------------------------------------------------------------------------- // Project GeometryKit // Class G3DLine // Creator Philippe C.D. Robert // Maintainer Philippe C.D. Robert // Creation Date Thu Sep 9 11:05:08 CEST 1999 // // Copyright (c) Philippe C.D. Robert // // The GeometryKit is free software; you can redistribute it and/or modify it // under the terms of the GNU LGPL Version 2 as published by the Free // Software Foundation // // $Id: G3DLine.h,v 1.8 2001/01/05 20:50:48 robert Exp $ //----------------------------------------------------------------------------- /* * Definition: L(t) = Origin + t * Direction, where Direction is normalised * */ #ifndef __G3DLine_h_INCLUDE #define __G3DLine_h_INCLUDE #import #import @class G3DVector3f; @class G3DTuple3f; @class G3DBox; @class G3DPlane; @class G3DSphere; @interface G3DLine : NSObject { G3DTuple3f *origin; G3DVector3f *direction; float t; } //----------------------------------------------------------------------------- // class methods //----------------------------------------------------------------------------- + (G3DLine *)line; + (G3DLine *)lineWithOrigin:(G3DTuple3f *)s endPoint:(G3DTuple3f *)e; + (G3DLine *)lineWithOrigin:(G3DTuple3f *)s direction:(G3DVector3f *)vec factor:(float)f; + (G3DLine *)lineWithLine:(G3DLine *)aLine; //----------------------------------------------------------------------------- // init and free //----------------------------------------------------------------------------- - (id)init; - (id)initWithOrigin:(G3DTuple3f *)s endPoint:(G3DTuple3f *)e; - (id)initWithOrigin:(G3DTuple3f *)s direction:(G3DVector3f *)vec factor:(float)f; // Designated initialiser, direction gets normalised - (id)initWithLine:(G3DLine *)aLine; - (void)dealloc; //----------------------------------------------------------------------------- // math //----------------------------------------------------------------------------- - (BOOL)isParallelLine:(G3DLine *)aLine; - (BOOL)intersectsObject:(id)anObject; - (BOOL)intersectsLine:(G3DLine *)ln; - (BOOL)intersectsSphere:(G3DSphere *)sphere; - (BOOL)intersectsBox:(G3DBox *)box; - (BOOL)intersectsPlane:(G3DPlane *)plane intersection:(G3DTuple3f *)pt; //----------------------------------------------------------------------------- // accessor methods //----------------------------------------------------------------------------- - (void)setFactor:(float)val; - (float)factor; - (G3DTuple3f *)origin; - (void)setOrigin:(G3DTuple3f *)o; - (G3DVector3f *)direction; - (void)setDirection:(G3DVector3f *)d; - (BOOL)isEqualToLine:(G3DLine *)aLine; //----------------------------------------------------------------------------- // NSCoding //----------------------------------------------------------------------------- - (void)encodeWithCoder:(NSCoder *)aCoder; - (id)initWithCoder:(NSCoder *)aCoder; //----------------------------------------------------------------------------- // NSCopying //----------------------------------------------------------------------------- - (id)copyWithZone:(NSZone *)zone; @end extern NSString *G3DLineException; #endif