Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/parametrics/nurbsMatrixVector.I

Go to the documentation of this file.
00001 // Filename: nurbsMatrixVector.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: NurbsMatrixVector::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE NurbsMatrixVector::
00026 NurbsMatrixVector() {
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: NurbsMatrixVector::Destructor
00031 //       Access: Public
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE NurbsMatrixVector::
00035 ~NurbsMatrixVector() {
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: NurbsMatrixVector::get_num_segments
00040 //       Access: Public
00041 //  Description: Returns the number of piecewise continuous segments
00042 //               in the curve.
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE int NurbsMatrixVector::
00045 get_num_segments() const {
00046   return _segments.size();
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: NurbsMatrixVector::get_start_t
00051 //       Access: Public
00052 //  Description: Returns the first legal value of t on the curve.
00053 //               Usually this is 0.0.
00054 ////////////////////////////////////////////////////////////////////
00055 INLINE float NurbsMatrixVector::
00056 get_start_t() const {
00057   nassertr(!_segments.empty(), 0.0f);
00058   return _segments.front()._from;
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: NurbsMatrixVector::get_end_t
00063 //       Access: Public
00064 //  Description: Returns the last legal value of t on the curve.
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE float NurbsMatrixVector::
00067 get_end_t() const {
00068   nassertr(!_segments.empty(), 0.0f);
00069   return _segments.back()._to;
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: NurbsMatrixVector::get_vertex_index
00074 //       Access: Public
00075 //  Description: Returns the vertex index of the nth segment.  This is
00076 //               the index number of the first associated control
00077 //               vertex within the source NurbsCurveEvaluator object.
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE int NurbsMatrixVector::
00080 get_vertex_index(int segment) const {
00081   nassertr(segment >= 0 && segment < (int)_segments.size(), 0);
00082   return _segments[segment]._vertex_index;
00083 }
00084 
00085 ////////////////////////////////////////////////////////////////////
00086 //     Function: NurbsMatrixVector::get_from
00087 //       Access: Public
00088 //  Description: Returns the t value of the beginning of this segment.
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE float NurbsMatrixVector::
00091 get_from(int segment) const {
00092   nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f);
00093   return _segments[segment]._from;
00094 }
00095 
00096 ////////////////////////////////////////////////////////////////////
00097 //     Function: NurbsMatrixVector::get_to
00098 //       Access: Public
00099 //  Description: Returns the t value of the end of this segment.
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE float NurbsMatrixVector::
00102 get_to(int segment) const {
00103   nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f);
00104   return _segments[segment]._to;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: NurbsMatrixVector::get_matrix
00109 //       Access: Public
00110 //  Description: Returns the matrix associated with the nth segment.
00111 ////////////////////////////////////////////////////////////////////
00112 INLINE const LMatrix4f &NurbsMatrixVector::
00113 get_matrix(int segment) const {
00114   nassertr(segment >= 0 && segment < (int)_segments.size(), LMatrix4f::ident_mat());
00115   return _segments[segment]._matrix;
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: NurbsMatrixVector::scale_t
00120 //       Access: Public
00121 //  Description: Scales the value of t into the range [0, 1]
00122 //               corresponding to [from, to].  Returns the scaled
00123 //               value.
00124 ////////////////////////////////////////////////////////////////////
00125 INLINE float NurbsMatrixVector::
00126 scale_t(int segment, float t) const {
00127   nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f);
00128   float from = _segments[segment]._from;
00129   float to = _segments[segment]._to;
00130   t = (t - from) / (to - from);
00131   return min(max(t, 0.0f), 1.0f);
00132 }

Generated on Fri May 2 00:40:46 2003 for Panda by doxygen1.3