cubic

Solving a cubic to find nearest point on a curve to a point

蹲街弑〆低调 提交于 2019-12-04 13:01:51
Ok, I have a projectile that has its position defined such that: a.x = initialX + initialDX * time; a.y = initialY + initialDY * time + 0.5 * gravtiy * time^2; I want to be able to predict which obstacles in my environment this projectile will collide with. I plan on checking the distance from A the closest point on the curve to the point P . I figure that at the point A the tangent to the curve will be perpendicular to the vector AP , and that the tangent to the curve at A will simply be the velocity V of the projectile at that point. AP dot V = 0 ap.x = initialX + initialDX * time - p.x; ap

Finding Y given X on a Cubic Bezier Curve?

喜你入骨 提交于 2019-12-04 01:01:44
I need a method that allows me to find the Y-coordinate on a Cubic Bezier Curve, given an x-coordinate. I've come across lots of places telling me to treat it as a cubic function then attempt to find the roots, which I understand. HOWEVER the equation for a Cubic Bezier curve is (for x-coords): X(t) = (1-t)^3 * X0 + 3*(1-t)^2 * t * X1 + 3*(1-t) * t^2 * X2 + t^3 * X3 What confuses me is the addition of the (1-t) values. For instance, if I fill in the X values with some random numbers: 400 = (1-t)^3 * 100 + 3*(1-t)^2 * t * 600 + 3*(1-t) * t^2 * 800 + t^3 * 800 then rearrange it: 800t^3 + 3*(1-t)

Get x on Bezier curve given y

早过忘川 提交于 2019-12-02 22:27:34
问题 I have a Bezier curve: (0,0) , (.25,.1) , (.25,1) , and (1,1) . This is graphically seen here: http://cubic-bezier.com/#.25,.1,.25,1 We see on the x axis is time. This is my unknown. This is a unit cell. So I was wondering how can I get x when y is 0.5? Thanks I saw this topic: y coordinate for a given x cubic bezier But it loops, I need to avoid something loops So I found this topic: Cubic bezier curves - get Y for given X But I can't figure out how to solve a cubic polynomial in js :( 回答1:

Extrapolate split cubic-bezier to 1,1

谁说胖子不能爱 提交于 2019-12-02 19:14:58
问题 I need help with the solution provided here. Create easy function 40% off set I need to modify it so that the returned left and rights are extrapolated to 1,1 after splitting. This is because if I don't extrapolate, I can't use the returned split cubic-bezier as a css transition. So this is the test I did. Please help because real does not match mike way :( I think the issue is I need to extrapolate the result to 1,1. I can't simply double the values though I'm pretty sure. REAL ease-in-out

Get x on Bezier curve given y

喜你入骨 提交于 2019-12-02 10:38:25
I have a Bezier curve: (0,0) , (.25,.1) , (.25,1) , and (1,1) . This is graphically seen here: http://cubic-bezier.com/#.25,.1,.25,1 We see on the x axis is time. This is my unknown. This is a unit cell. So I was wondering how can I get x when y is 0.5? Thanks I saw this topic: y coordinate for a given x cubic bezier But it loops, I need to avoid something loops So I found this topic: Cubic bezier curves - get Y for given X But I can't figure out how to solve a cubic polynomial in js :( This is mathematically impossible unless you can guarantee that there will only be one y value per x value,

Extrapolate split cubic-bezier to 1,1

房东的猫 提交于 2019-12-02 10:17:33
I need help with the solution provided here. Create easy function 40% off set I need to modify it so that the returned left and rights are extrapolated to 1,1 after splitting. This is because if I don't extrapolate, I can't use the returned split cubic-bezier as a css transition. So this is the test I did. Please help because real does not match mike way :( I think the issue is I need to extrapolate the result to 1,1. I can't simply double the values though I'm pretty sure. REAL ease-in-out is cubic-bezier(.42,0,.58,1) and graphically is http://cubic-bezier.com/#.42,0,.58,1 first half is ease

Why am I receiving a “no ordering relation defined for complex numbers” error?

孤人 提交于 2019-12-01 19:32:46
See this question for some background. My main problem on that question was solved, and it was suggested that I ask another one for a second problem I'm having: print cubic(1, 2, 3, 4) # Correct solution: about -1.65 ... if x > 0: TypeError: no ordering relation is defined for complex numbers print cubic(1, -3, -3, -1) # Correct solution: about 3.8473 if x > 0: TypeError: no ordering relation is defined for complex numbers Cubic equations with one real root and two complex roots are receiving an error, even though I am using the cmath module and have defined the cube root function to handle

What's wrong with this function to solve cubic equations?

天涯浪子 提交于 2019-12-01 05:35:43
问题 I am using Python 2 and the fairly simple method given in Wikipedia's article "Cubic function". This could also be a problem with the cube root function I have to define in order to create the function mentioned in the title. # Cube root and cubic equation solver # # Copyright (c) 2013 user2330618 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, you can obtain one at http://www.mozilla.org/MPL

Cubic Regression (best fit line) in JavaScript

坚强是说给别人听的谎言 提交于 2019-11-29 12:48:40
I'm having the worst time trying to find a JavaScript code that could allow me to do cubic regressions. Would write it myself, but my understanding of polynomial math is, well, suboptimal. So, here's what I'm looking for. Given an input of an array of arrays, where the internal array would be [x,y], the function would give me an output in the form of an array with four parameters - [a,b,c,d], where a, b, c, and d are parameters of the equation y = ax^3 + bx^2 + cx + d. Example: Input is an array like this [[2,5],[5,10],[07,15],[12,20],[20,25],[32,30],[50,35]]. Which essentially is the

Create easy function 40% off set

荒凉一梦 提交于 2019-11-28 14:39:57
I have animation follows this timing function: cubic-bezier(0.25, 0.1, 0.25, 1.0) I want to mod this function so i just get the ending 40% of it. To make things easy lets just say I want the end 50% of the function. How can I do this. So graphically this is what it is: https://developer.mozilla.org/files/3429/cubic-bezier,ease.png and I want to to make a cubic-bezier with parameters such that graphically we only see the top portion, so what we see from 0.5 to 1 (on the yaxist) porition of this graph, i want to make that same line but from 0 to 1. Please help me how to make this function. If