UNPKG

1.57 kBMarkdownView Raw
1# Sigma Current Coordinate System
2
3## Referentials
4
51. Graph coordinates `graph`: arbitrary, range from `-Infinity` to `Infinity`.
62. Rescaled graph coordinates `rescaled`: centered on `0.5`, proportion between min/max of `graph`. Ranges naturally from `0` to `1`.
73. Container pixel coordinates `container`: origin is top left and range from `0` to max pixel width/height.
84. Webgl coordinates `webgl`: centered on `0`, screen space ranges from `-1` to `1`.
95. Quadtree coordinates `quadtree`: same as `rescaled` with `-1`. Can't remember why but won't work else. `quadtree` also normalize sizes by dividing them by container width.
10
11## Translations
12
13* `renderers/utils.createNormalizationFunction`: creates a function mapping `graph` to `rescaled`. It also returns an inverse function mappping `rescaled` to `graph`. It must be actualized every time `graph` coordinates are updated (can be optimized by recomputing only if bounds changed).
14* `camera.graphToViewport`: maps `rescaled` to `container`.
15* `camera.viewportToGraph`: maps the inverse `container` to `rescaled`.
16* `renderers/webgl/utils.matrixFromCamera`: return a translation matrix to map `rescaled` to `webgl` and used in vertex shaders.
17
18## Examples
19
20### Click detection
21
221. Find nodes in the quadtree using event positions.
232. Apply size ratio of the camera.
243. Map node positions from `rescaled` (cache) to `container`.
254. Compute collisions.
26
27### Drag
28
291. Map event positions from `container` to `rescaled`.
302. Use inverse normalization function to map `rescaled` to `graph`.
313. Set position in `graph`.