00001 // Filename: nurbsCurveResult.I 00002 // Created by: drose (04Dec02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: NurbsCurveResult::Destructor 00022 // Access: Published 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE NurbsCurveResult:: 00026 ~NurbsCurveResult() { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: NurbsCurveResult::get_start_t 00031 // Access: Public 00032 // Description: Returns the first legal value of t on the curve. 00033 // Usually this is 0.0. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE float NurbsCurveResult:: 00036 get_start_t() const { 00037 return _prod.get_start_t(); 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: NurbsCurveResult::get_end_t 00042 // Access: Public 00043 // Description: Returns the last legal value of t on the curve. 00044 //////////////////////////////////////////////////////////////////// 00045 INLINE float NurbsCurveResult:: 00046 get_end_t() const { 00047 return _prod.get_end_t(); 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: NurbsCurveResult::eval_point 00052 // Access: Published 00053 // Description: Computes the point on the curve corresponding to the 00054 // indicated value in parametric time. Returns true if 00055 // the t value is value, false otherwise. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE bool NurbsCurveResult:: 00058 eval_point(float t, LVecBase3f &point) { 00059 int segment = find_segment(t); 00060 if (segment == -1) { 00061 return false; 00062 } 00063 00064 eval_segment_point(segment, _prod.scale_t(segment, t), point); 00065 return true; 00066 } 00067 00068 //////////////////////////////////////////////////////////////////// 00069 // Function: NurbsCurveResult::eval_tangent 00070 // Access: Published 00071 // Description: Computes the tangent to the curve at the indicated 00072 // point in parametric time. This tangent vector will 00073 // not necessarily be normalized, and could be zero. 00074 // See also eval_point(). 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE bool NurbsCurveResult:: 00077 eval_tangent(float t, LVecBase3f &tangent) { 00078 int segment = find_segment(t); 00079 if (segment == -1) { 00080 return false; 00081 } 00082 00083 eval_segment_tangent(segment, _prod.scale_t(segment, t), tangent); 00084 return true; 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: NurbsCurveResult::get_num_segments 00089 // Access: Public 00090 // Description: Returns the number of piecewise continuous segments 00091 // within the curve. This number is usually not 00092 // important unless you plan to call 00093 // eval_segment_point(). 00094 //////////////////////////////////////////////////////////////////// 00095 INLINE int NurbsCurveResult:: 00096 get_num_segments() const { 00097 return _prod.get_num_segments(); 00098 } 00099 00100 //////////////////////////////////////////////////////////////////// 00101 // Function: NurbsCurveResult::get_segment_t 00102 // Access: Public 00103 // Description: Accepts a t value in the range [0, 1], and assumed to 00104 // be relative to the indicated segment (as in 00105 // eval_segment_point()), and returns the corresponding 00106 // t value in the entire curve (as in eval_point()). 00107 //////////////////////////////////////////////////////////////////// 00108 INLINE float NurbsCurveResult:: 00109 get_segment_t(int segment, float t) const { 00110 return t * (_prod.get_to(segment) - _prod.get_from(segment)) + _prod.get_from(segment); 00111 }