NewField creates a new vector field plotter.
(f FieldXY)
| 64 | |
| 65 | // NewField creates a new vector field plotter. |
| 66 | func NewField(f FieldXY) *Field { |
| 67 | max := math.Inf(-1) |
| 68 | c, r := f.Dims() |
| 69 | for i := range c { |
| 70 | for j := range r { |
| 71 | v := f.Vector(i, j) |
| 72 | d := math.Hypot(v.X, v.Y) |
| 73 | if math.IsNaN(d) { |
| 74 | continue |
| 75 | } |
| 76 | max = math.Max(max, d) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return &Field{ |
| 81 | FieldXY: f, |
| 82 | LineStyle: DefaultLineStyle, |
| 83 | max: max, |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Plot implements the Plot method of the plot.Plotter interface. |
| 88 | func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) { |