Add Mul2D to Point{,F,F32}.
This commit is contained in:
parent
e34821ab87
commit
a7a4688687
7
point.go
7
point.go
@ -80,11 +80,16 @@ func (p Point) Less(q Point) bool {
|
||||
return p.Y < q.Y
|
||||
}
|
||||
|
||||
// Mul multiplier the X and Y values of point p with t and returns the result.
|
||||
// Mul multiplies the X and Y values of point p with t and returns the result.
|
||||
func (p Point) Mul(t int) Point {
|
||||
return Pt(p.X*t, p.Y*t)
|
||||
}
|
||||
|
||||
// Mul2D multiplies the X and Y values of point p with x and y and returns the result.
|
||||
func (p Point) Mul2D(x, y int) Point {
|
||||
return Pt(p.X*x, p.Y*y)
|
||||
}
|
||||
|
||||
// Norm returns the point with both X and Y normalized.
|
||||
func (p Point) Norm() Point {
|
||||
return Pt(ints.Norm(p.X), ints.Norm(p.Y))
|
||||
|
@ -132,11 +132,16 @@ func (p PointF) Invert() PointF {
|
||||
return PointF{-p.X, -p.Y}
|
||||
}
|
||||
|
||||
// Mul multiplier the X and Y values of point p with t and returns the result.
|
||||
// Mul multiplies the X and Y values of point p with t and returns the result.
|
||||
func (p PointF) Mul(t float64) PointF {
|
||||
return PtF(p.X*t, p.Y*t)
|
||||
}
|
||||
|
||||
// Mul2D multiplies the X and Y values of point p with x and y and returns the result.
|
||||
func (p PointF) Mul2D(x, y float64) PointF {
|
||||
return PtF(p.X*x, p.Y*y)
|
||||
}
|
||||
|
||||
// Rect returns a rectangle starting from point p to given point q
|
||||
func (p PointF) Rect(q PointF) RectangleF {
|
||||
return RectangleF{Min: p, Max: q}
|
||||
|
@ -132,11 +132,16 @@ func (p PointF32) Invert() PointF32 {
|
||||
return PointF32{-p.X, -p.Y}
|
||||
}
|
||||
|
||||
// Mul multiplier the X and Y values of point p with t and returns the result.
|
||||
// Mul multiplies the X and Y values of point p with t and returns the result.
|
||||
func (p PointF32) Mul(t float32) PointF32 {
|
||||
return PtF32(p.X*t, p.Y*t)
|
||||
}
|
||||
|
||||
// Mul2D multiplies the X and Y values of point p with x and y and returns the result.
|
||||
func (p PointF32) Mul2D(x, y float32) PointF32 {
|
||||
return PtF32(p.X*x, p.Y*y)
|
||||
}
|
||||
|
||||
// Rect returns a rectangle starting from point p to given point q
|
||||
func (p PointF32) Rect(q PointF32) RectangleF32 {
|
||||
return RectangleF32{Min: p, Max: q}
|
||||
|
Loading…
Reference in New Issue
Block a user