-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_ilerp.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: pbondoer <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2016/05/11 01:06:57 by pbondoer #+# #+# */ | ||
/* Updated: 2016/05/11 01:42:28 by pbondoer ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
double ft_ilerp(double val, double first, double second) | ||
{ | ||
if (val == first) | ||
return (0.0); | ||
if (val == second) | ||
return (1.0); | ||
return ((val - first) / (second - first)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_lerp.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: pbondoer <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2016/05/11 00:34:09 by pbondoer #+# #+# */ | ||
/* Updated: 2016/05/11 01:42:49 by pbondoer ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
double ft_lerp(double first, double second, double p) | ||
{ | ||
if (first == second) | ||
return (first); | ||
return (first + (second - first) * p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_lerpi.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: pbondoer <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2016/05/11 00:34:09 by pbondoer #+# #+# */ | ||
/* Updated: 2016/05/11 01:43:03 by pbondoer ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
int ft_lerpi(int first, int second, double p) | ||
{ | ||
if (first == second) | ||
return (first); | ||
return ((int)((double)first + (second - first) * p)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: pbondoer <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2015/11/24 19:59:25 by pbondoer #+# #+# */ | ||
/* Updated: 2016/02/26 04:21:16 by pbondoer ### ########.fr */ | ||
/* Updated: 2016/05/11 01:21:15 by pbondoer ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -88,4 +88,7 @@ int ft_max(int a, int b); | |
int ft_abs(int i); | ||
int ft_iswhitespace(char c); | ||
size_t ft_countwords(char *str, char c); | ||
double ft_lerp(double first, double second, double p); | ||
double ft_ilerp(double val, double first, double second); | ||
int ft_lerpi(int first, int second, double p); | ||
#endif |