//=======================================================================// // File: line.cpp // // Project: Architecture // // Author: J.M. Albertson // //-----------------------------------------------------------------------// // Copyright (C) 1994, Virtual World Entertainments, All Rights reserved // // PROPRIETARY AND CONFIDENTIAL // //=======================================================================// #include #pragma hdrstop #if !defined(LINE_HPP) # include #endif #if !defined(PLANE_HPP) # include #endif // //########################################################################### //########################################################################### // Line& Line::operator=(const Vector3D &vector) { Check_Pointer(this); Check(&vector); // // Make sure length of vector is non-zero // length = vector.Length(); Verify(length); // // Normalize the vector and put it into the line // direction.x = vector.x/length; direction.y = vector.y/length; direction.z = vector.z/length; return *this; } // //########################################################################### //########################################################################### // Line& Line::operator=(const Point3D &point) { Check_Pointer(this); Check(&point); // // Copy the point over into the line. // origin.x = point.x; origin.y = point.y; origin.z = point.z; return *this; } Scalar Line::DistanceTo( const Plane &plane, Scalar *product ) const { *product = direction * plane.normal; if (Small_Enough(*product)) { Check_Fpu(); return -1.0f; } Scalar result = -plane.DistanceTo(origin) / *product; Check_Fpu(); return result; } Scalar Line::DistanceTo( const Sphere &,//sphere, Scalar *//penetration ) const { return -1.0f; // HACK }