Panda3D
nurbsCurveInterface.I
1 // Filename: nurbsCurveInterface.I
2 // Created by: drose (02Mar01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: NurbsCurveInterface::append_cv
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE int NurbsCurveInterface::
22 append_cv(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
23  return append_cv(LVecBase3(x, y, z));
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: NurbsCurveInterface::append_cv
28 // Access: Published
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE int NurbsCurveInterface::
32 append_cv(const LVecBase3 &v) {
33  return append_cv(LVecBase4(v[0], v[1], v[2], 1.0f));
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: NurbsCurveInterface::append_cv
38 // Access: Published
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 INLINE int NurbsCurveInterface::
42 append_cv(const LVecBase4 &v) {
43  return append_cv_impl(v);
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: NurbsCurveInterface::set_cv_point
48 // Access: Public, Scheme
49 // Description: Repositions the indicated CV. Returns true if
50 // successful, false otherwise.
51 ////////////////////////////////////////////////////////////////////
52 INLINE bool NurbsCurveInterface::
53 set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
54  return set_cv_point(n, LVecBase3(x, y, z));
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: NurbsCurveInterface::set_cv_point
59 // Access: Public, Scheme
60 // Description: Repositions the indicated CV. Returns true if
61 // successful, false otherwise.
62 ////////////////////////////////////////////////////////////////////
63 INLINE bool NurbsCurveInterface::
64 set_cv_point(int n, const LVecBase3 &v) {
65  nassertr(n >= 0 && n < get_num_cvs(), false);
66  return set_cv(n, LVecBase4(v[0], v[1], v[2], 1.0f) * get_cv_weight(n));
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: NurbsCurveInterface::get_cv_point
71 // Access: Public, Scheme
72 // Description: Returns the position of the indicated CV.
73 ////////////////////////////////////////////////////////////////////
75 get_cv_point(int n) const {
76  nassertr(n >= 0 && n < get_num_cvs(), LVecBase3::zero());
77  LVecBase4 p = get_cv(n);
78  nassertr(p[3] != 0.0f, LVecBase3::zero());
79  return LVecBase3(p[0], p[1], p[2]) / p[3];
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: NurbsCurveInterface::get_cv_weight
84 // Access: Published
85 // Description: Returns the weight of the indicated CV.
86 ////////////////////////////////////////////////////////////////////
87 INLINE PN_stdfloat NurbsCurveInterface::
88 get_cv_weight(int n) const {
89  return get_cv(n)[3];
90 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
static const LVecBase3f & zero()
Returns a zero-length vector.
Definition: lvecBase3.h:382
PN_stdfloat get_cv_weight(int n) const
Returns the weight of the indicated CV.
bool set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Repositions the indicated CV.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
LVecBase3 get_cv_point(int n) const
Returns the position of the indicated CV.