Skip to content

Commit

Permalink
plotter: address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Apr 4, 2019
1 parent e4119b4 commit c7c0a3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions plotter/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type FieldXY interface {
// Dims returns the dimensions of the grid.
Dims() (c, r int)

// Vector returns the value of a grid value at (c, r).
// It will panic if c or r are out of bounds for the grid.
// Vector returns the value of a vector field at (c, r).
// It will panic if c or r are out of bounds for the field.
Vector(c, r int) XY

// X returns the coordinate for the column at the index x.
// X returns the coordinate for the column at the index c.
// It will panic if c is out of bounds for the grid.
X(c int) float64

Expand Down Expand Up @@ -52,8 +52,7 @@ type Field struct {
max float64
}

// NewField creates as new heat map plotter for the given data,
// using the provided palette.
// NewField creates a new vector field plotter.
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
Expand Down
4 changes: 2 additions & 2 deletions plotter/field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func (f field) Dims() (c, r int) { return f.c, f.r }
func (f field) Vector(c, r int) plotter.XY { return f.fn(f.X(c), f.Y(r)) }
func (f field) X(c int) float64 {
if c < 0 || c >= f.c {
panic("index out of range")
panic("column index out of range")
}
return float64(c - f.c/2)
}
func (f field) Y(r int) float64 {
if r < 0 || r >= f.r {
panic("index out of range")
panic("row index out of range")
}
return float64(r - f.r/2)
}
Expand Down

0 comments on commit c7c0a3c

Please sign in to comment.