You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-1Lines changed: 61 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,7 @@ A *Real Renderer* is a fancy name for a class that is exported by this package.
45
45
#### List of Real Renderers
46
46
- [`RealRenderer`](#realrenderer)
47
47
- [`RealLineGraph`](#reallinegraph)
48
+
- [`RealComplexSpace`](#realcomplexspace)
48
49
49
50
#### `RealRenderer`
50
51
This is the base class. It does not have any specific use. It can only display a blank graph with coordinate axes on it. See [example](https://harshkhandeparkar.github.io/gpujs-real-renderer).
- `reset()`: Resets the pixels on the graph to a blank graph with the coordinate axes.
100
101
101
-
#### RealLineGraph
102
+
#### `RealLineGraph`
102
103
This Real Renderer extends the `RealRenderer` class and can be used to plot generated data in real-time as the data is obtained. This can be used to analyze data that changes over time.
103
104
104
105
This is a generic line graph with straight lines joining points. (The first point connects to the origin)
@@ -143,6 +144,65 @@ The returned object contains two properties `x` and `y` each of which are arrays
143
144
144
145
- `reset()`: This is the same method as that of `RealRenderer` but it also resets the axes and the plots.
145
146
147
+
#### `RealComplexSpace`
148
+
This Real Renderer extends the `RealRenderer` class and can be used to plot changing complex numbers. A few watched numbers are plotted every time the renderer renders. A callback is fired just before the render, to change the numbers.
149
+
150
+
This class provides another class, `Complex`, to define, manipulate, add, subtract, multiply etc. complex numbers.
151
+
152
+
See [example](https://harshkhandeparkar.github.io/gpujs-real-renderer).
153
+
154
+
##### Properties (Read-Only)
155
+
- `Complex` (*Class*): A class for defining and manipulating complex numbers. Has the following methods.
156
+
- `constructor(r, theta)`: Default constructor with r(modulus) and theta(argument) (polar form of a complex number).
157
+
- `getCartesianForm()`: A method that returns the x and y coordinates of the same complex number in cartesian form, as an array of the form `[x, y]`.
158
+
- `getPolarForm()`: A method that returns the r(modulus) and theta(argument) of the same complex number in polar form, as an array of the form `[r, theta]`.
159
+
- `add(addedNum)`: Adds another number `addedNum` which is another object of `Complex` class to itself and returns the output. Also edits itself.
160
+
- `subtract(subtractedNum)`: Subtracts another number `subtractedNum` which is another object of `Complex` class from itself and returns the output. Also edits itself.
161
+
- `multiply(multipliedNum)`: Multiplies another number `multipliedNum` which is another object of `Complex` class to itself and returns the output. Also edits itself.
162
+
- `divide(dividedNum)`: Divides itself by another number `dividedNum` which is another object of `Complex` class and returns the output. Also edits itself.
163
+
- `conjugate()`: Modifies itself to be its own complex conjugate and returns itself.
164
+
- `reciprocal()`: Modifies itself to be its own reciprocal and returns itself.
165
+
NOTE: All of the above methods except `getCartesianForm` and `getPolarForm` are chainable.
166
+
167
+
- `watchedNumbers`(*Object*): An object that stores all the *watched* complex numbers, ie the ones that are plotted during each render. This object is of the form
168
+
```js
169
+
{
170
+
name1: { // Here, `name` is any arbitrary name, the property does not matter
171
+
number:Complex(), // The complex number
172
+
show: boolean, // Whether to show/plot the number or not
173
+
persistent: boolean, // Whether the number's older locations will persist on the graph or disappear in the next render (see example)
174
+
interpolate: boolean, // Whether to interpolate (ie draw a line between this number and another number, see example for use cases)
175
+
interpolateTo:Complex(), // Draws a line between this number and the watched number
Since this is a child class of `RealRenderer`, all the options of `RealRender` are applicable here as well.
184
+
Apart from those, the following are additional options that can be passed on to the constructor.
185
+
186
+
- `brushSize`(*Number*) (Default: `1`): Determines the size of the brush, i.e. the radius of the plotted points, in pixels.
187
+
188
+
- `brushColor`(*Array*) (Default: `[1, 1, 1]`): The color of the brush, i.e. the plotted points.
189
+
190
+
- `lineThickness`(*Number*) (Default: `0.05`): The thickness of the line joining the different plotted points, in coordinate units with scaleFactors.
191
+
192
+
- `lineColor`(*Array*) (Default: `[0, 0.5, 0]`): The color of the line joining different points.
193
+
194
+
- `changeNumbers(watchedNumbers, time)`(*Function*) (Default: `function(watchedNumbers) {return watchedNumbers}`): A callback that is fired at the start of every render. The first argument is the object of watched numbers (see above properties), the second argument is the internal `time` variable which can be used to keep track of render time.
195
+
The expected return type is a similar object(but can be changed).
196
+
197
+
##### Methods
198
+
Since this is a child class of `RealRenderer`, all the methods of `RealRender` are available here as well.
199
+
Apart from these methods, the following new methods are also available and are chainable too.
200
+
201
+
- `watch(name, number, show =true, persistent =true, interpolate =false, interpolateTo =null, attributes = {})`: Add a new number to the `watchedNumbers`, see properties above.
202
+
203
+
- `clearWatched()`: Clears all watched numbers.
204
+
205
+
- `plot(number)`: Plots a single `number`, an instance of `Complex` class.
0 commit comments