Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions snippets/c/mathematical-functions/linear-mapping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Linear Remappibg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

description: remaps a value from one range to another
author: JasimAlrawie
tags: math,number-theory,algebra
---

```c

float linearMapping(float value, float minIn, float maxIn, float minOut, float maxOut) {
return (v-minIn) * (maxOut - minOut)/(maxIn - minIn) + minOut
}


// Usage:
linearMapping(value, 0, 1, 0, 255) // remaps the value from (0,1) to (0,255)
linearMapping(value, 0, PI*2, 0, 360) // remaps the value from rad to deg
linearMapping(value, -1, 1, 1, 8) // remaps the value from (-1,1) to (1,8)
```
17 changes: 17 additions & 0 deletions snippets/javascript/mathematical-functions/linear-mapping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Linear Remapping
description: remaps a value from one range to another
author: JasimAlrawie
tags: math,number-theory,algebra
---

```js
function linearMapping(value, minIn, maxIn, minOut, maxOut) {
return (v-minIn) * (maxOut - minOut)/(maxIn - minIn) + minOut
}

// Usage:
linearMapping(value, 0, 1, 0, 255) // remaps the value from (0,1) to (0,255)
linearMapping(value, 0, PI*2, 0, 360) // remaps the value from rad to deg
linearMapping(value, -1, 1, 1, 8) // remaps the value from (-1,1) to (1,8)
```
17 changes: 17 additions & 0 deletions snippets/python/math-and-numbers/linear-mapping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Linear Renapping
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

description: remaps a value from one range to another
author: JasimAlrawie
tags: math,number-theory,algebra
---

```py

def linearMapping(value, minIn, maxIn, minOut, maxOut):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be lower_cased to follow pep8 standard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake case ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

return (value - minIn) * (maxOut - minOut) / (maxIn - minIn) + minOut

// Usage:
linearMapping(value, 0, 1, 0, 255) // remaps the value from (0,1) to (0,255)
linearMapping(value, 0, PI*2, 0, 360) // remaps the value from rad to deg
linearMapping(value, -1, 1, 1, 8) // remaps the value from (-1,1) to (1,8)
```
Loading