-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math - remap function #220
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: Linear Remappibg | ||
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) | ||
``` |
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) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Linear Renapping | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be lower_cased to follow pep8 standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. snake case ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo