Reputation: 327
I would like to transform the number beings used to create this slope/sine in the sample below to "inverse" numbers that I am showing in the goal image below.
So; A value that is close to 1 would transform to something close to 0. A value that is close to -1 would transform to something close to 0. A positive value that is close to 0 would transform to something close to 1. A negative value that is close to 0 would transform to something close to -1.
Unfortunately I don't know how to better phrase the question. I don't think I actually want "inverse" numbers, so hopefully my request makes sense. I am trying to understand what Math logic I can use to achieve my goal.
Thank you.
Upvotes: 1
Views: 251
Reputation: 9221
I think you want something like this:
public static double Transform(double x) {
if (Math.Abs(x) > 1) Throw new ArgumentException("Absolute value must be less or equals than 1");
return Math.Sign(x) - x;
}
Upvotes: 1