Questions tagged [math-functions]
56 questions
1
vote
2 answers
Finding the object property with the highest value where the property is a decimal
I'm currently using:
last = Math.max.apply(Math, response.data.map((o: any) => {
return o.name;
}))
to find the object with the highest 'name' value within response.data array. Despite 16.12 being the largest value, it returns 16.9 as I think…

Nats
- 160
- 3
- 20
1
vote
1 answer
Which sigmoid function to use for increasing contrast of an image?
Is there a standard sigmoidal function used to increase the contrast in a gray level bitmap?
Currently I am using the following. This would be applied to gray levels represented at values between 0 and 1 inclusive.
static double ContrastCurve(double…

jwezorek
- 8,592
- 1
- 29
- 46
1
vote
0 answers
What is the fastest fabsf (floating point absolute value function) implementation in c#?
I am in the process of optimizing the most demanding function in a Unity 3d game. The most costly subroutine is the unity Mathf.Abs method which is being called on floating point values(NEVER DOUBLES). In cases, calls to this function are adding…
1
vote
2 answers
Get the min and max value in android studio
what I am trying to do, is get the minimun and maximun value from some float values I put manually. But I do not know how to do it. any helping coidng would be great. Thank you.
Asume a list of floats
p1, p2, p3, p4, p5, p6, p7, p8, p9

jvargas
- 713
- 1
- 5
- 13
1
vote
1 answer
How can I temporary or permanently change the math formula colors in Wikipedia pages?
The question in the caption is sufficiently verbose imho.
The background for it is my dark browser theme (I hate bright whites) in which black text (e.g. the Wikipedia-math-formulas) are not readable.
Further info: the said formulas are svg-files…

Steffen W.
- 21
- 4
1
vote
2 answers
C# trigonometric functions / math functions
I'm writing a class which should calculate angles (in degrees), after long trying I don't get it to work.
When r = 45 & h = 0 sum should be around 77,14°
but it returns NaN - Why? I know it must be something with the Math.Atan-Method and a not…

maddy
- 13
- 4
1
vote
1 answer
unity Mathf.PerlinNoise not between 0 and 1
Does anybody know why this:
Debug.Log(Mathf.PerlinNoise(190911.45f, 2290937.40f));
gives me: 1.044323 It should have been between 0 and 1 isn't it?
And if it can get bigger than 1 can it get smaller than 0? I'm making a map with sprites…

Danielle Geelen
- 13
- 4
1
vote
1 answer
Using Mathf.Clamp without effecting y axis.
I have a script that makes my camera follow the mouse. Works fine but I want the camera to only be able to move so far so I used this.
transform.position = new Vector3(Mathf.Clamp(transform.position.x, 1.5f, -1.4f), 0, -10);
It works to stop the…

RedDragon2001
- 39
- 6
1
vote
1 answer
Python xpath and math operators
I am trying to calculate the tax of a numerical value extracted with xpath, to save it in a csv file, but I do not know what I am doing wrong or if I need to add something else.
This the code:
import math
for ntp in…

Valter
- 27
- 8
1
vote
1 answer
How to point to the center coordinates of a specific object in 2D in Unity?
Before questioning, I declare that I am a beginner.
Please understand that there may be a lack of explanation.
I'll explain what I want to implement with pictures and code.
Below is a picture.
Like the picture above, I have implemented the present…

Seongwon-Choi
- 459
- 8
- 24
0
votes
0 answers
How do I graph an input function?
With pyplot you can plot a function with
x = np.linspace(-10, 10, num=100) #start x, end x, number of points on line
fx = []
for i in range(len(x)):
fx.append(-2*x[i]**3 - 35*x[i]**2 + 39*x[i] + 70) #creates function f(x)
plt.plot(x, fx) #plots…

Lain
- 16
- 4
0
votes
0 answers
Why does math.floor() round up numbers after 15 decimal places in python?
I am trying to calculate the floor value of certain numbers.
It works fine when I run this: math.floor(9.999999999999999) .
I get the output as 9 . This number has 15 decimal places.
However, math.floor() seems to fail after 15 decimal places.
When…

Kanika Nadar
- 13
- 1
0
votes
0 answers
Get an offset behind player forward without target
I need a constant offest behind the player forward based on player rotation and player position. So if the player rotate or move this offset is always at a costant position behind the player forward. For example if this variable has the value 10 i…

Vincent Mazzarella
- 11
- 7
0
votes
0 answers
Ignore rotation when using transform.translate. [Topdown 2D]
This is part of the logic from my movement code:
transform.Translate(velocity * Time.deltaTime);
velocity.x = Mathf.MoveTowards(velocity.x, runSpeed * moveInputX, changeRatePerSecond * Time.deltaTime);
velocity.y = Mathf.MoveTowards(velocity.y,…
0
votes
1 answer
How to create a (math) function for the position of a billiard ball when considering friction
so I'm creating a billiard ball simulation. The current version I have calculates the new position of the ball for each step, but I would like to create a math function (f(x)) for the balls position. This is not too hard, but what is really tripping…

Noob
- 3
- 1