add Vec.Apply
This commit is contained in:
parent
767a5a8b13
commit
a7fdbd618e
|
@ -97,6 +97,15 @@ func (u Vec) Cross(v Vec) float64 {
|
||||||
return u.X()*v.Y() - v.X()*u.Y()
|
return u.X()*v.Y() - v.X()*u.Y()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply applies the function f to both x and y components of the vector u and returns the modified
|
||||||
|
// vector.
|
||||||
|
func (u Vec) Apply(f func(float64) float64) Vec {
|
||||||
|
return V(
|
||||||
|
f(u.X()),
|
||||||
|
f(u.Y()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Rect is a 2D rectangle aligned with the axes of the coordinate system. It has a position
|
// Rect is a 2D rectangle aligned with the axes of the coordinate system. It has a position
|
||||||
// and a size.
|
// and a size.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue