vunordered?
vmax
vmin
+ vclamp
vsupremum
vinfimum
}
{ $description "Creates a sequence where each element is the minimum of the corresponding elements from " { $snippet "u" } " and " { $snippet "v" } "." }
{ $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmin ." "{ -7 2 3 }" } } ;
+HELP: vclamp
+{ $values { "v" "a sequence of real numbers" } { "min" "a sequence of real numbers" } { "max" "a sequence of real numbers" } }
+{ $description "Creates a sequence where each element is clamped to the minimum and maximum elements of the " { $snippet "min" } " and " { $snippet "max" } " sequences." }
+{ $examples
+ { $example
+ "USING: math.vectors prettyprint ;"
+ "{ -10 30 120 } { 0 0 0 } { 100 100 100 } vclamp ."
+ "{ 0 30 100 }"
+ }
+} ;
+
HELP: v.
{ $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "x" "a real number" } }
{ $description "Computes the dot product of two vectors." } ;
GRAVITY v+ ;
: clamp-coords ( coords dim -- coords' )
- [ { 0 0 } vmax ] dip { 2 2 } v- vmin ;
+ { 0 0 } swap { 2 2 } v- vclamp ;
:: pixel-indices ( coords dim -- indices )
coords vfloor v>integer dim clamp-coords :> floor-coords