[英]Is there a method to either recalculate and equation in terms of a different variable?
I am currently a senior in AP Calculus BC and have taken the challenge of replicating a topic in C++ Qt.我目前是 AP Calculus BC 的大四学生,并接受了在 C++ Qt 中复制主题的挑战。 This topic covers integrals as area beneath a curve, and rotations of said areas to form a solid model with a definite volume.
本主题涵盖作为曲线下方面积的积分,以及所述面积的旋转以形成具有确定体积的实心 model。
I have successfully rotated a custom equation defined as:我已经成功旋转了一个自定义方程,定义为:
double y = abs(qSin(qPow(graphXValue,graphXValue))/qPow(2, (qPow(graphXValue,graphXValue)-M_PI/2)/M_PI))
OR或者
My question is how to rotate such an equation around the Y-Axis instead of the X-Axis.我的问题是如何围绕 Y 轴而不是 X 轴旋转这样的方程。 Are there any methods to approximate the solving of this equation in terms of y instead of x?
有没有什么方法可以用 y 而不是 x 来近似求解这个方程? Are there any current implementations of such a task?
目前是否有此类任务的任何实现?
Keep in mind, I am calculating each point for the transformation in a 3D coordinate system:请记住,我正在计算 3D 坐标系中转换的每个点:
for (float x = 0.0f; x < t_functionMaxX - t_projectionStep; x+=t_projectionStep)
{
currentSet = new QSurfaceDataRow;
nextSet = new QSurfaceDataRow;
float x_pos_mapped = x;
float y_pos_mapped = static_cast<float>(ui->customPlot->graph(0)->data()->findBegin(static_cast<double>(x), true)->value);
float x_pos_mapped_ahead = x + t_projectionStep;
float y_pos_mapped_ahead = static_cast<float>(graph1->data()->findBegin(static_cast<double>(x + t_projectionStep), true)->value);
QList<QVector3D> temp_points;
for (float currentRotation = static_cast<float>(-2*M_PI); currentRotation < static_cast<float>(2*M_PI); currentRotation += static_cast<float>((1) * M_PI / 180))
{
float y_pos_calculated = static_cast<float>(qCos(static_cast<qreal>(currentRotation))) * y_pos_mapped;
float z_pos_calculated = static_cast<float>(qSin(static_cast<qreal>(currentRotation))) * y_pos_mapped;
float y_pos_calculated_ahead = static_cast<float>(qCos(static_cast<qreal>(currentRotation))) * y_pos_mapped_ahead;
float z_pos_calculated_ahead = static_cast<float>(qSin(static_cast<qreal>(currentRotation))) * y_pos_mapped_ahead;
QVector3D point(x_pos_mapped, y_pos_calculated, z_pos_calculated);
QVector3D point_ahead(x_pos_mapped_ahead, y_pos_calculated_ahead, z_pos_calculated_ahead);
*currentSet << point;
*nextSet << point_ahead;
temp_points << point;
}
*data << currentSet << nextSet;
points << temp_points;
}
Essentially, you rotate the vector (x,f(x),0)
around the Y axis, so the Y value remains the same but the X and Y parts vary according to rotation.本质上,您围绕 Y 轴旋转矢量
(x,f(x),0)
,因此 Y 值保持不变,但 X 和 Y 部分会根据旋转而变化。
I also replaced all the static_cast<float>
parts by explicit invocations of the float
constructor, which (I find) reads a bit better.我还通过显式调用
float
构造函数替换了所有static_cast<float>
部分,(我发现)读起来更好一些。
// Render the upper part, grow from the inside
for (float x = 0.0f; x < t_functionMaxX - t_projectionStep; x+=t_projectionStep)
{
currentSet = new QSurfaceDataRow;
nextSet = new QSurfaceDataRow;
float x_pos_mapped = x;
float y_pos_mapped = float(ui->customPlot->graph(0)->data()->findBegin(double(x), true)->value);
float x_pos_mapped_ahead = x + t_projectionStep;
float y_pos_mapped_ahead = float(graph1->data()->findBegin(double(x + t_projectionStep), true)->value);
QList<QVector3D> temp_points;
for (float currentRotation = float(-2*M_PI); currentRotation < float(2*M_PI); currentRotation += float((1) * M_PI / 180))
{
float x_pos_calculated = float(qCos(qreal(currentRotation))) * x_pos_mapped;
float z_pos_calculated = float(qSin(qreal(currentRotation))) * x_pos_mapped;
float x_pos_calculated_ahead = float(qCos(qreal(currentRotation))) * x_pos_mapped_ahead;
float z_pos_calculated_ahead = float(qSin(qreal(currentRotation))) * x_pos_mapped_ahead;
QVector3D point(x_pos_calculated, y_pos_mapped, z_pos_calculated);
QVector3D point_ahead(x_pos_calculated_ahead, y_pos_mapped_ahead, z_pos_calculated_ahead);
*currentSet << point;
*nextSet << point_ahead;
temp_points << point;
}
*data << currentSet << nextSet;
points << temp_points;
}
Next, you need to add the bottom "plate".接下来,您需要添加底部“盘子”。 This is simply a bunch of triangles that connect
(0,0,0)
with two adjacent points of the rotation of (1,0,0)
around the Y axis, just like we did above.这只是一堆三角形,它们将
(0,0,0)
与(1,0,0)
绕 Y 轴旋转的两个相邻点连接起来,就像我们上面所做的那样。
Finally, if f(t_functionmaxX)
is not zero, you need to add a side that connects (t_functionmaxX, f(t_functionmaxX), 0)
to (t_functionmaxX, 0, 0)
, again rotating in steps around the Y axis.最后,如果
f(t_functionmaxX)
不为零,则需要添加连接(t_functionmaxX, f(t_functionmaxX), 0)
到(t_functionmaxX, 0, 0)
的边,再次绕 Y 轴逐步旋转。
Note that this will do weird things if y < 0. How you want to solve that is up to you.请注意,如果 y < 0,这会做一些奇怪的事情。你想如何解决这个问题取决于你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.