Questions tagged [lerp]

Lerp is a function which Interpolates between two values in a specific time `t` to create smooth animations.

Linearly interpolates between two vectors.

Interpolates between a and b by t. t is clamped between 0 and 1. It is used to create smooth changes of all type of ui controls. Changing the Audio, a Color or transform values of an game object in unity3d can be done with Lerp easily.

Documentation

170 questions
10
votes
3 answers

Equidistant points between two points?

I am trying to know equidistant points between two points. For example: p1 = (1,1) p2 = (5,5) The answer that I am expecting is: def getEquidistantPoints(p1, p2, HowManyParts): #some code return (array with points) In this example, with…
mikesneider
  • 772
  • 2
  • 10
  • 28
6
votes
1 answer

What are the differences between the two lerp functions?

In Floating point linear interpolation one user proposed this implementation of lerp: float lerp(float a, float b, float f) { return (a * (1.0 - f)) + (b * f); } While another user proposed this implementation of a lerp: float lerp(float a,…
tempdev nova
  • 211
  • 1
  • 8
6
votes
4 answers

C# Lerping from position to position

I need to make a picture box to lerp from position to position (like you can do that in unity). How can I do that , is there a built-in function? thanks :)
Paz Haviv
  • 137
  • 1
  • 1
  • 10
4
votes
4 answers

Unity awaitForSeconds called before lerp animation ends

I have created a simple lerp animation that moves an object from one place to the other using this code: public IEnumerator Move(Vector3 position, Transform transform, float animationTime = 1) { float timePassed = 0; transform.position =…
SagiZiv
  • 932
  • 1
  • 16
  • 38
4
votes
1 answer

Use MoveTowards with duration instead of speed

I want to move GameObject from position A to B with Vector3.MoveTowards within x seconds and in a coroutine function. I know how to do this with Vector3.Lerp but this time would prefer to do it with Vector3.MoveTowards since both functions behave…
Programmer
  • 121,791
  • 22
  • 236
  • 328
4
votes
1 answer

Unity-I can't seem to lerp my GameObject's Color

I'm just trying to make an observer pattern program one object randomly changes color and causes a group of other objects to change the same color, but I wanted them to gradually change over 5 seconds. I'm trying lerp, but it just instantly swaps…
user8048595
  • 119
  • 1
  • 2
  • 12
4
votes
1 answer

Symmetrical Lerp & compiler optimizations

I had a function: float lerp(float alpha, float x0, float x1) { return (1.0f - alpha) * x0 + alpha * x1; } For those who haven't seen it, this is preferable to x0 + (x1-x0) * alpha because the latter doesn't guarantee that lerp(1.0f, x0, x1)…
Ben
  • 9,184
  • 1
  • 43
  • 56
3
votes
1 answer

(Three.JS) How to loop/lerp through more than two colors (three colors)?

I'm working on a project in the Three.JS Online Editor. I'm trying to make a Day / Night Cycle. It should loop through colors, setting the scene background colors, like this: Day Sunrise/Sunset Night Sunrise/Sunset Day ... Etc., etc., And it…
Fox GAMING_NTF
  • 153
  • 2
  • 14
3
votes
1 answer

8 Bit LERP with SSE

I have been trying to figure out the best way to use AMD64 SIMD instructions to implement a lerp to be used with large sets of u8 values but I can't seem to figure out the correct instructions without requiring all the SIMD extensions. The formula I…
gudenau
  • 500
  • 5
  • 19
3
votes
0 answers

how to smoothly trasit from higher value to lower value or vice versa in interpolation

I have a game character which rotates in both direction.I am using interpolation to make rotation smooth a bit. Angle limit is 0 to 2PI in clockwise and 0 to -2PI in anticlockwise direction. Interpolation works well between any value between 0 to +-…
JustStarted
  • 130
  • 5
3
votes
1 answer

Unity - how to fast forward to a percentage of animation?

Ok, I have looked up everything to do with Unity's Animator, and I know you can jump to specific frames and get percentage of animation with https://answers.unity.com/questions/1418940/how-can-i-know-a-percent-of-animation.html and…
blue
  • 7,175
  • 16
  • 81
  • 179
3
votes
2 answers

Lerp the alpha value of a color

I want to change the alpha value (transparency) of a color back and forth: private void Awake() { material = gameObject.GetComponent().material; oColor = material.color; // the alpha here is 0 nColor = material.color; …
Abdou023
  • 1,654
  • 2
  • 24
  • 45
2
votes
3 answers

Smoothly lerping between vectors where speed and distance is inconsistent and/or noisy

I'm visualising GPS data provided from the cars in races in Formula 1, and am attempting to animate their position on a path. The Formula 1 API provides vector coordinates and timestamps, but the timestamps are varied: they're updated approximately…
dave
  • 2,750
  • 1
  • 14
  • 22
2
votes
1 answer

Rotating meshes on an ellipse curve with mousewheel delta

I have positioned some plane meshes distributed evenly on an ellipse curve line. On the animation loop, i'm moving them around on the ellipse curve with curve.getPointAt and time delta, then applying the matrix. however, im also trying to add a…
wsgg
  • 934
  • 1
  • 20
  • 43
2
votes
1 answer

How to make html element lerp towards cursor in vanilla Javascript?

I'm trying to recreate the button effect on this website: https://advanced.team/team Scroll down until you see this You can move your mouse around the div, even outside of the div itself a little bit and it will lerp towards the cursor. I'm trying…
i am bad at coding
  • 555
  • 1
  • 3
  • 14
1
2 3
11 12