1 /* === S I N F G =========================================================== */
2 /*! \file valuenode_segcalctangent.cpp
3 ** \brief Template File
5 ** $Id: valuenode_segcalctangent.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "valuenode_segcalctangent.h"
32 #include "valuenode_const.h"
33 #include "valuenode_composite.h"
35 #include "exception.h"
36 #include <ETL/hermite>
37 #include <ETL/calculus>
42 /* === U S I N G =========================================================== */
46 using namespace sinfg;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 ValueNode_SegCalcTangent::ValueNode_SegCalcTangent(const ValueBase::Type &x):
59 if(x!=ValueBase::TYPE_VECTOR)
60 throw Exception::BadType(ValueBase::type_name(x));
62 segment_=ValueNode_Composite::create(ValueBase::TYPE_SEGMENT);
63 amount_=ValueNode_Const::create(Real(0.5));
66 ValueNode_SegCalcTangent*
67 ValueNode_SegCalcTangent::create(const ValueBase &x)
69 return new ValueNode_SegCalcTangent(x.get_type());
72 ValueNode_SegCalcTangent::~ValueNode_SegCalcTangent()
78 ValueNode_SegCalcTangent::operator()(Time t)const
80 Segment segment((*segment_)(t).get(Segment()));
82 etl::hermite<Vector> curve(segment.p1,segment.p2,segment.t1,segment.t2);
83 etl::derivative< etl::hermite<Vector> > deriv(curve);
85 #ifdef ETL_FIXED_DERIVATIVE
86 return deriv((*amount_)(t).get(Real()))*(0.5);
88 return deriv((*amount_)(t).get(Real()))*(-0.5);
95 ValueNode_SegCalcTangent::get_name()const
97 return "segcalctangent";
101 ValueNode_SegCalcTangent::get_local_name()const
103 return _("SegCalcTangent");
107 ValueNode_SegCalcTangent::check_type(ValueBase::Type type)
109 return type==ValueBase::TYPE_VECTOR;
113 ValueNode_SegCalcTangent::set_link_vfunc(int i,ValueNode::Handle x)
115 assert(i==0 || i==1);
119 signal_child_changed()(i);signal_value_changed()();
125 signal_child_changed()(i);signal_value_changed()();
131 ValueNode::LooseHandle
132 ValueNode_SegCalcTangent::get_link_vfunc(int i)const
134 assert(i==0 || i==1);
144 ValueNode_SegCalcTangent::link_count()const
150 ValueNode_SegCalcTangent::link_name(int i)const
152 assert(i==0 || i==1);
161 ValueNode_SegCalcTangent::link_local_name(int i)const
163 assert(i==0 || i==1);
172 ValueNode_SegCalcTangent::get_link_index_from_name(const String &name)const
179 throw Exception::BadLinkName(name);
183 ValueNode_SegCalcTangent::create_new()const
185 return new ValueNode_SegCalcTangent(ValueBase::TYPE_VECTOR);