Javascript 给定曲线的最大高度,获得二次曲线的Y值
当Y为100时,曲线的最大高度将为(+/-)60。当我有曲线的最大高度时,我需要一种方法来计算Y 代码: 点1和点2具有x、y和z坐标Javascript 给定曲线的最大高度,获得二次曲线的Y值,javascript,math,Javascript,Math,当Y为100时,曲线的最大高度将为(+/-)60。当我有曲线的最大高度时,我需要一种方法来计算Y 代码: 点1和点2具有x、y和z坐标 this.drawLine = function(point1, point2) { context = this.getContext(); context.beginPath(); context.moveTo(this.getX(point1), this.getY(point1)); point3 = {
this.drawLine = function(point1, point2) {
context = this.getContext();
context.beginPath();
context.moveTo(this.getX(point1), this.getY(point1));
point3 = {
x: ( point1.x + point2.x ) / 2,
y: ( point1.y + point2.y ) / 2,
z: ( point1.z + point2.z ) / 2
}
context.quadraticCurveTo( this.getX(point3), this.getY(point3) + point3.z * 0, this.getX(point2), this.getY(point2));
context.stroke();
}
我需要曲线的直线到达点3的坐标,而不是它没有到达坐标。仍然有许多可能的曲线具有相同的最大值。因此,不能孤立一条曲线来计算Y值 我建议找到一种方法来获取有关曲线的更多信息,例如点、属性或关系 查看以下链接: 找到了我的答案:
请考虑在你的问题中增加一些信息。如果您不确定还要添加什么。。。也许有一点背景就好了。你有没有一个特定的方程式用来画曲线?
this.drawLine = function(point1, point2, style) {
context = this.getContext();
context.beginPath();
context.moveTo(this.getX(point1), this.getY(point1));
point3 = {
x: ( point1.x + point2.x ) / 2,
y: ( point1.y + point2.y ) / 2,
z: ( point1.z + point2.z ) / 2
}
context.strokeStyle = style;
x = this.getX(point3) * 2 - ( this.getX(point1) + this.getX(point2) ) / 2;
y = this.getY(point3) * 2 - ( this.getY(point1) + this.getY(point2) ) / 2;
context.quadraticCurveTo( x, y, this.getX(point2), this.getY(point2));
context.stroke();
}