Draws vectors showing the direction field of the differential equation. In a graph of Y vs. X, shows the value of the derivative dy/dx at various points on a grid, as a short line with that slope.

This is a static display that is typically layered over a DisplayGraph. The DisplayGraph will be drawing the actual graph lines.

This is generally only useful for differential equations of 2 variables. Otherwise, the phase space is 3D, 4D, etc. and cannot be adequately represented by these direction field vectors.

The screen rectangle that the VectorGraph should occupy within the SimView must be set with setScreenRect before drawing can be done.

Redraws when a parameter changes in the subject, because a parameter change modifies the direction field.

TO DO Optionally, make length of the vector be proportional to the speed of the trajectory at that point.

Implements

Constructors

  • Parameters

    • sim: ODESim

      the simulation whose differential equations will be shown as a direction field

    • xVariable: number

      index of X variable in VarsList of sim

    • yVariable: number

      index of Y variable in VarsList of sim

    Returns VectorGraph

Properties

dotStyle: string = 'red'

The color to use for drawing dots, a CSS3 color value.

gridPoints: number = 10

Number of grid points to have in each direction, horizontally and vertically.

lastMap_: null | CoordMap = null

to detect when redraw needed; when the coordmap changes, we need to redraw.

lineStyle: string = 'blue'

The color to use for drawing lines, a CSS3 color value.

needRedraw_: boolean = true

set when the entire graph needs to be redrawn.

offScreen_: null | HTMLCanvasElement = null

The offscreen buffer to draw the graph into

xVariable_: number

index of x variable in VarsList

yVariable_: number

index of y variable in VarsList

Methods

  • Whether the DisplayObject contains the given world coordinates point.

    Parameters

    • _p_world: Vector

      the point in world coordinates

    Returns boolean

    true if this DisplayObject contains the given point

  • Draws this DisplayObject using the given CoordMap.

    Parameters

    • context: CanvasRenderingContext2D

      the canvas's context to draw this object into

    • map: CoordMap

      the mapping to use for translating between simulation and screen coordinates

    Returns void

  • Draws the entire graph into the given Graphics context.

    Parameters

    • context: CanvasRenderingContext2D

      the canvas's context to draw into

    • coordMap: CoordMap

      the CoordMap specifying sim to screen conversion

    Returns void

  • Sets the z-index which specifies front-to-back ordering of objects; objects with a higher zIndex are drawn over (in front of) objects with a lower zIndex.

    Returns number

    the zIndex of this DisplayObject

  • Notifies this Observer that a change has occurred in the Subject.

    Parameters

    • event: SubjectEvent

      contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

    Returns void

  • Sets whether this DisplayObject is currently dragable; has no effect on objects that are not dragable.

    Parameters

    • _dragable: boolean

      whether this DisplayObject should be dragable

    Returns void

  • Sets this DisplayObject's position in simulation coordinates of the containing SimView. Each type of DisplayObject has a different policy regarding whether this will have an effect. Generally the policies are:

    • If the DisplayObject does not represent a SimObject, then the position can be set. Examples are DisplayClock, EnergyBarGraph.

    • If the SimObject's position is dependent on other objects, then the position cannot be set. Examples are DisplayConnector, DisplayRope, DisplaySpring.

    • If the SimObject can be moved independently and isDragable is true, then the position of the SimObject is modified. Example: DisplayShape.

    Parameters

    • _position: GenericVector

      this DisplayObject's position, in simulation coordinates.

    Returns void

  • Sets the screen rectangle that this VectorGraph should occupy within the SimView, in screen coordinates.

    Parameters

    • screenRect: ScreenRect

      the screen coordinates of the area this VectorGraph should occupy.

    Returns void

  • Sets the z-index which specifies front-to-back ordering of objects; objects with a higher zIndex are drawn over objects with a lower zIndex. Default is zero.

    Parameters

    • zIndex: number

      the zIndex of this DisplayObject

    Returns void

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc