diff --git a/README.md b/README.md index 9d6f4f2..657d6dd 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ For a more complete list, refer to [Wikipedia - List of Mathematical Symbols](ht # contents -- [variable conventions](#variable-conventions) -- [dot & cross `×` `·`](#dot-cross) +- [variable name conventions](#variable-name-conventions) +- [dot & cross `×` `·`](#dot--cross) - [scalar multiplication](#scalar-multiplication) - [vector multiplication](#vector-multiplication) - [dot product](#dot-product) @@ -29,22 +29,27 @@ For a more complete list, refer to [Wikipedia - List of Mathematical Symbols](ht - [Euclidean norm](#euclidean-norm) - [determinant](#determinant) - [hat **`â`**](#hat) - *unit vector* +- [equals `=` `≈` `≠` `=:`](#equals-symbols) +- [element `∈` `∉`](#element) + - [such that](#such-that) - [more...](#more) -## variable conventions +## variable naming conventions -There are a variety of conventions depending on the context and field of study, and they are not always consistent. However, in some of the literature you may find variable names to follow a pattern like so: +There are a variety of naming conventions depending on the context and field of study, and they are not always consistent. However, in some of the literature you may find variable names to follow a pattern like so: - *s* - italic lowercase letters for scalars (i.e. a number) - **x** - bold lowercase letters for vectors (i.e. a 2D point) - **A** - bold uppercase letters for matrices (i.e. a 3D transformation) - *θ* - italic lowercase Greek letters for constants and special variables (i.e. [polar angle *θ*, *theta*](https://en.wikipedia.org/wiki/Spherical_coordinate_system)) +This will also be the format of this guide. + ## dot & cross The dot `·` and cross `×` symbols have different uses depending on context. -These might seem obvious, but it's important to understand the subtle differences before we continue into other sections. +They might seem obvious, but it's important to understand the subtle differences before we continue into other sections. #### scalar multiplication @@ -371,6 +376,82 @@ Other implementations: - [gl-vec3/normalize](https://github.com/stackgl/gl-vec3/blob/507480fa57ba7c5fb70679cf531175a52c48cf53/normalize.js) and [gl-vec2/normalize](https://github.com/stackgl/gl-vec2/blob/21f460a371540258521fd2f720d80f14e87bd400/normalize.js) - [vectors/normalize-nd](https://github.com/hughsk/vectors/blob/master/normalize-nd.js) (n-dimensional) +## equals symbols + +There are a number of symbols resembling the equals sign `=`. Here is a few common ones and an example of their use: + +- `=` is for equality (values are the same) +- `≠` is for inequality (value are not the same) +- `≈` is for approximately equal to (`π ≈ 3.14159`) + +In JavaScript: + +```js +// equality +2 === 3 + +// inequality +2 !== 3 + +// approximately equal +almostEqual(Math.PI, 3.14159, 1e-5) + +function almostEqual(a, b, epsilon) { + return Math.abs(a - b) <= epsilon +} +``` + +The `:=` `=:` and `=` symbols can be used for *definition*. The following defines *x* to be another name for 2*kj*. + +![equals1](img/equals1.png) + + + +Code: + +```js +var x = 2 * k * j +``` + + + +## element + +In set theory, the "element of" symbol `∈` and `∋` can be used to describe whether something is an element of a set. For example: + +![element1](img/element1.png) + + + +Here we have a set of numbers *A* `[ 3, 9, 14 ]` and we are saying `3` is an "element of" that set. In code: + +```js +var A = [ 3, 9, 14 ] + +A.indexOf(3) >= 0 +//=> true +``` + +The backwards `∋` is the same, but the order changes: + +![element2](img/element2.png) + + + +You can also use the "not an element of" symbols `∉` and `∌` like so: + +![element3](img/element3.png) + + + ## more... Like this guide? Suggest some [more features](https://github.com/Jam3/math-as-code/issues/1) or send us a Pull Request! diff --git a/img/element1.png b/img/element1.png new file mode 100644 index 0000000..139599f Binary files /dev/null and b/img/element1.png differ diff --git a/img/element2.png b/img/element2.png new file mode 100644 index 0000000..f1db1e1 Binary files /dev/null and b/img/element2.png differ diff --git a/img/element3.png b/img/element3.png new file mode 100644 index 0000000..6d846e0 Binary files /dev/null and b/img/element3.png differ diff --git a/img/equals1.png b/img/equals1.png new file mode 100644 index 0000000..83c5eb8 Binary files /dev/null and b/img/equals1.png differ diff --git a/img/equals2.png b/img/equals2.png new file mode 100644 index 0000000..6120f8b Binary files /dev/null and b/img/equals2.png differ