::tclinterp::approximationTop, Main, Index
CommandsTop, Main, Index
bezier [::tclinterp::approximation]Top, Main, Index
Finds values of Bezier function at x points.
bezier -n value -a value -b value -x list -y list
Parameters
-a value | Start of the interval. |
-b value | End of interval. |
-n value | Order of Bezier function, must be zero or more. |
-x list | List of x values. |
-y list | List of y control points values of size n+1. |
Return value
yi values of Bezier function at x points
proc ::tclinterp::approximation::bezier {args} {
# Finds values of Bezier function at x points.
# -n value - order of Bezier function, must be zero or more
# -a value - start of the interval
# -b value - end of interval
# -x list - list of x values
# -y list - list of y control points values of size n+1
# Returns: yi values of Bezier function at x points
# Synopsis: -n value -a value -b value -x list -y list
argparse -help {Finds values of Bezier function at x points. Returns: yi values of Bezier function at x points} {
{-n= -required -help {Order of Bezier function, must be zero or more} -type integer -validate {$arg>0} -errormsg {Order of Bezier curve -n '$arg' must be more than or equal to zero}}
{-a= -required -help {Start of the interval}}
{-b= -required -help {End of interval}}
{-x= -required -help {List of x values}}
{-y= -required -help {List of y control points values of size n+1}}
}
if {$a==$b} {
return -code error "Start -a '$a' and end -b '$b' values of interval must not be equal"
}
set xLen [llength $x]
set yLen [llength $y]
if {$yLen!=[= {$n+1}]} {
return -code error "Length of -y '$yLen' must be equal to n+1=[= {$n+1}]"
} elseif {$xLen==0} {
return -code error {Length of points list -x must be more than zero}
}
::tclinterp::Lists2arrays yArray [list $y]
for {set i 0} {$i<$xLen} {incr i} {
lappend yiList [::tclinterp::bez_val $n [@ $x $i] $a $b $yArray]
}
::tclinterp::DeleteArrays $yArray
return $yiList
}cubicBetaSpline1d [::tclinterp::approximation]Top, Main, Index
Evaluates a cubic beta spline approximant.
cubicBetaSpline1d -beta1 value -beta2 value -t|x list -y list -ti|xi list
Parameters
-beta1 value | The skew or bias parameter, beta1 = 1 for no skew or bias. |
-beta2 value | The tension parameter, beta2 = 0 for no tension. |
-t list | List of independent variable (t) values, -x is an alias. |
-ti list | List of independent variable interpolation (ti) values, -xi is an alias. |
-y list | List of dependent variable (y) values. |
Return value
list of approximation values yi at ti points.
proc ::tclinterp::approximation::cubicBetaSpline1d {args} {
# Evaluates a cubic beta spline approximant.
# -beta1 value - the skew or bias parameter, beta1 = 1 for no skew or bias
# -beta2 value - the tension parameter, beta2 = 0 for no tension
# -t list - list of independent variable (t) values, -x is an alias
# -y list - list of dependent variable (y) values
# -ti list - list of independent variable interpolation (ti) values, -xi is an alias
# Returns: list of approximation values yi at ti points.
# Synopsis: -beta1 value -beta2 value -t|x list -y list -ti|xi list
argparse -help {Evaluates a cubic beta spline approximant. Returns: list of approximation values yi at ti points} {
{-beta1= -required -type double -help {The skew or bias parameter, beta1 = 1 for no skew or bias}}
{-beta2= -required -type double -help {The tension parameter, beta2 = 0 for no tension}}
{-t= -required -alias x -help {List of independent variable (t) values}}
{-y= -required -help {List of dependent variable (y) values}}
{-ti= -required -alias xi -help {List of independent variable interpolation (ti) values}}
}
set tLen [llength $t]
set yLen [llength $y]
set tiLen [llength $ti]
if {$tLen!=$yLen} {
return -code error "Length of -y '$yLen' must be equal to length of -t '$tLen'"
} elseif {$tiLen==0} {
return -code error {Length of interpolation points list -ti must be more than zero}
}
::tclinterp::Lists2arrays {tArray yArray} [list $t $y]
for {set i 0} {$i<$tiLen} {incr i} {
set iElem [::tclinterp::spline_beta_val $beta1 $beta2 $tLen $tArray $yArray [@ $ti $i]]
lappend yiList $iElem
}
::tclinterp::DeleteArrays $tArray $yArray
return $yiList
}cubicBSpline1d [::tclinterp::approximation]Top, Main, Index
Evaluates a cubic B spline approximant.
cubicBSpline1d -t|x list -y list -ti|xi list
Parameters
-t list | List of independent variable (t) values, -x is an alias. |
-ti list | List of independent variable interpolation (ti) values, -xi is an alias. |
-y list | List of dependent variable (y) values. |
Return value
list of approximation values yi at ti points.
proc ::tclinterp::approximation::cubicBSpline1d {args} {
# Evaluates a cubic B spline approximant.
# -t list - list of independent variable (t) values, -x is an alias
# -y list - list of dependent variable (y) values
# -ti list - list of independent variable interpolation (ti) values, -xi is an alias
# Returns: list of approximation values yi at ti points.
# Synopsis: -t|x list -y list -ti|xi list
argparse -help {Evaluates a cubic B spline approximant. Returns: list of approximation values yi at ti points} {
{-t= -required -alias x -help {List of independent variable (t) values}}
{-y= -required -help {List of dependent variable (y) values}}
{-ti= -required -alias xi -help {List of independent variable interpolation (ti) values}}
}
set tLen [llength $t]
set yLen [llength $y]
set tiLen [llength $ti]
if {$tLen!=$yLen} {
return -code error "Length of -y '$yLen' must be equal to length of -t '$tLen'"
} elseif {$tiLen==0} {
return -code error {Length of interpolation points list -ti must be more than zero}
}
::tclinterp::Lists2arrays {tArray yArray} [list $t $y]
for {set i 0} {$i<$tiLen} {incr i} {
set iElem [::tclinterp::spline_b_val $tLen $tArray $yArray [@ $ti $i]]
lappend yiList $iElem
}
::tclinterp::DeleteArrays $tArray $yArray
return $yiList
}genBezier [::tclinterp::approximation]Top, Main, Index
Finds values of general Bezier function at specified t points.
genBezier -n value -x list -y list -t list
Parameters
-n value | Order of Bezier function, must be zero or more. |
-t list | List of t points at which we want to evaluate Bezier function, best results are obtained within the interval [0,1] |
-x list | List of x control points values of size n+1. |
-y list | List of y control points values of size n+1. |
Return value
dict with lists of xi and yi points at specified t points
proc ::tclinterp::approximation::genBezier {args} {
# Finds values of general Bezier function at specified t points.
# -n value - order of Bezier function, must be zero or more
# -x list - list of x control points values of size n+1
# -y list - list of y control points values of size n+1
# -t list - list of t points at which we want to evaluate Bezier function, best results are obtained within the interval
# [0,1]
# Returns: dict with lists of xi and yi points at specified t points
# Synopsis: -n value -x list -y list -t list
argparse -help {Finds values of general Bezier function at specified t points. Returns: dict with lists of xi and yi points at specified t points} {
{-n= -required -help {Order of Bezier function, must be zero or more} -type integer -validate {$arg>0} -errormsg {Order of Bezier curve -n '$arg' must be more than or equal to zero}}
{-x= -required -help {List of x control points values of size n+1}}
{-y= -required -help {List of y control points values of size n+1}}
{-t= -required -help {List of t points at which we want to evaluate Bezier function, best results are obtained within the interval [0,1]}}
}
set xLen [llength $x]
set yLen [llength $y]
set tLen [llength $t]
if {$xLen!=[= {$n+1}]} {
return -code error "Length of -x '$xLen' must be equal to n+1=[= {$n+1}]"
} elseif {$yLen!=[= {$n+1}]} {
return -code error "Length of -y '$yLen' must be equal to n+1=[= {$n+1}]"
} elseif {$tLen==0} {
return -code error {Length of points list -t must be more than zero}
}
::tclinterp::Lists2arrays {xArray yArray} [list $x $y]
::tclinterp::NewDoubleps {xiPnt yiPnt}
for {set i 0} {$i<$tLen} {incr i} {
::tclinterp::bc_val $n [@ $t $i] $xArray $yArray $xiPnt $yiPnt
lappend xiList [::tclinterp::doublep_value $xiPnt]
lappend yiList [::tclinterp::doublep_value $yiPnt]
}
::tclinterp::DeleteArrays $xArray $yArray
::tclinterp::DeleteDoubleps $xiPnt $yiPnt
return [dcreate xi $xiList yi $yiList]
}