Code Monkey home page Code Monkey logo

vector-field-demo's Introduction

vector-field-demo

This is an interactive Java application to demonstrate what vector fields are and how they work.

Uses exp4j, a free library for evaluating functions.

Features

  • Visualize vector field of arbitrary 2D vector-valued function
  • Click to drop a point that "flows" through the field
  • Click and hold, dragging a rectangular region, to drop a rectangle that will also "flow" through the field
  • When there is a point, see instantaneous values (Values tab)
  • Change window size to better visualize function

Controls

Function

As a 2D vector-valued function, it has an i-vector component and a j-vector component, both of which are functions of x and y.

Any valid function of x and y will be accepted, including trigonometric functions; anything that exp4j supports.

After changing the function, you must press the "Update Vector Field" button for the visualization to update.

Speed

Controls the internal delay used between updating the position of the point (or points, in the case of a rectangle) when having dropped one onto the field.

For cases where larger amounts of computation is involved, changing the speed bar may have little effect; consider changing the resolution instead (see below).

Resolution

Points are essentially moved through approximating a differential by taking very small "steps" according to the current vector, resolution determines the size of these steps.

A higher resolution will make it more precise, and will give more accuracy according to the path that should be expected, although this is likely not noticeable.

A lower resolution may cause noticeable deviance from expected behavior in certain cases, but often will not make a difference. Lowering resolution can also be very useful when computation load is high (such as dropping a rectangle), and may grant a considerable speed boost.

Figure (Side) Resolution

Rectangle movement is done through representing it with a large number of points along the edges of the rectangles, and then simply moving each point individually according to the vector field. Figure (Side) Resolution determines the number of points that represents each side of the rectangle.

In simple vector fields, it may happen that the entire edge moves together through the field, and the points stay collinear indefinitely. In these cases, a lower figure resolution will help reduce computational load as no "bending" of an edge will occur anyways.

In vector fields where this is not the case, typically at some point the distortion of a side will be so great that it visibly has "sharp edges", because the points representing the edge are no longer sufficient to show the smooth distortion. A higher figure resolution will help this issue; but only an infinite number of points can truly represent an edge, and likely, if you drop a rectangle and leave it for long enough, this sharp distortion will eventually become visible regardless of how high you set figure resolution.

Note that figure resolution determines how high to set the resolution of any new rectangle that is dropped, and changing it while there is already one moving through the vector field will have no impact on it.

Screenshots

screenshot_01screenshot_02 screenshot_03screenshot_04 screenshot_05screenshot_06 screenshot_07screenshot_08

vector-field-demo's People

Contributors

nthistle avatar

Watchers

James Cloos avatar  avatar

Forkers

joelz575

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.