增加sag和swing,不考虑在这些函数里面绘图。
Signed-off-by: facat <facat@facat.com>
This commit is contained in:
parent
53bc81b989
commit
bde8c2f462
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TransmissionGraphic.Graphic;
|
using TransmissionGraphic.Graphic;
|
||||||
using TransmissionGraphic.Type3D;
|
using TransmissionGraphic.Type3D;
|
||||||
|
using MathNet.Numerics.LinearAlgebra;
|
||||||
|
|
||||||
namespace TransmissionGraphic
|
namespace TransmissionGraphic
|
||||||
{
|
{
|
||||||
|
|
@ -13,8 +14,13 @@ namespace TransmissionGraphic
|
||||||
{
|
{
|
||||||
Canvas canvas = new Canvas();
|
Canvas canvas = new Canvas();
|
||||||
canvas.init_canvas();
|
canvas.init_canvas();
|
||||||
Line line = new Line(canvas,new TGVector3D(10, 20, 10), new TGVector3D(400, 25, 35), 0.32e-3, 400);
|
Line line = new Line(new TGVector3D(10, 20, 10), new TGVector3D(400, 25, 35), 0.32e-3, 400);
|
||||||
canvas.draw(line.curve());
|
canvas.draw(line.curve());
|
||||||
|
Tuple<Matrix<double>, double> sag_and_value = line.sag();
|
||||||
|
Matrix<double> sag_points = sag_and_value.Item1;
|
||||||
|
double sag_value = sag_and_value.Item2;
|
||||||
|
canvas.draw(sag_points);
|
||||||
|
canvas.draw(line.swing(30 / 180 * Math.PI));
|
||||||
canvas.save("abc.dxf");
|
canvas.save("abc.dxf");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ namespace TransmissionGraphic.Graphic
|
||||||
private double _span;
|
private double _span;
|
||||||
private Matrix<double> _points;
|
private Matrix<double> _points;
|
||||||
private Rotation _rotation;
|
private Rotation _rotation;
|
||||||
private Canvas _canvas;
|
public Line(TGVector3D start_p, TGVector3D end_p, double tension_k, int n_point)
|
||||||
public Line(Canvas canvas, TGVector3D start_p, TGVector3D end_p, double tension_k, int n_point)
|
|
||||||
{
|
{
|
||||||
this._start_p = start_p;
|
this._start_p = start_p;
|
||||||
this._end_p = end_p;
|
this._end_p = end_p;
|
||||||
|
|
@ -28,11 +27,10 @@ namespace TransmissionGraphic.Graphic
|
||||||
this._span = 0;
|
this._span = 0;
|
||||||
this._points = null;
|
this._points = null;
|
||||||
this._rotation = null;
|
this._rotation = null;
|
||||||
this._canvas = canvas;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix<double> curve(bool draw = false)
|
public Matrix<double> curve()
|
||||||
{
|
{
|
||||||
if (this._points != null)
|
if (this._points != null)
|
||||||
{
|
{
|
||||||
|
|
@ -66,7 +64,51 @@ namespace TransmissionGraphic.Graphic
|
||||||
|
|
||||||
this._rotation = rotation;
|
this._rotation = rotation;
|
||||||
Matrix<double> points = rotation.rotate(Matrix<double>.Build.DenseOfArray(p_points));
|
Matrix<double> points = rotation.rotate(Matrix<double>.Build.DenseOfArray(p_points));
|
||||||
|
this._points = points;
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Matrix<double> swing(double angel)
|
||||||
|
{
|
||||||
|
if (this._points == null)
|
||||||
|
{
|
||||||
|
this.curve();
|
||||||
|
}
|
||||||
|
Matrix<double> points = this._points;
|
||||||
|
TGVector3D start_p = this._start_p;
|
||||||
|
TGVector3D end_p = this._end_p;
|
||||||
|
Rotation swing_rotation = new Rotation(
|
||||||
|
angel,
|
||||||
|
new TGVector3D(start_p.x, start_p.y, start_p.z),
|
||||||
|
new TGVector3D(end_p.x, end_p.y, end_p.z)
|
||||||
|
);
|
||||||
|
Matrix<double> swing_point = swing_rotation.rotate(points);
|
||||||
|
return swing_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tuple<Matrix<double>, double> sag()
|
||||||
|
{
|
||||||
|
TGVector3D start_p = this._start_p;
|
||||||
|
TGVector3D end_p = this._end_p;
|
||||||
|
double span = this._span;
|
||||||
|
double height = end_p.z - start_p.z;
|
||||||
|
double middle_span = span / 2;
|
||||||
|
Matrix<double> points = this._points;
|
||||||
|
int n_point = this._n_point;
|
||||||
|
double middle_z = points.At(Convert.ToInt32(n_point / 2), 2);
|
||||||
|
Rotation rotation = this._rotation;
|
||||||
|
Matrix<double> p_sag_points = Matrix<double>.Build.DenseOfArray(new double[,] {
|
||||||
|
{start_p.x, start_p.y, start_p.z},
|
||||||
|
{ middle_span + start_p.x, start_p.y, start_p.z + middle_span * height / span },
|
||||||
|
{middle_span + start_p.x, start_p.y, middle_z},
|
||||||
|
{ middle_span + start_p.x, start_p.y, start_p.z + middle_span * height / span },
|
||||||
|
{start_p.x + span, start_p.y, end_p.z},
|
||||||
|
});// 旋转前的值
|
||||||
|
Matrix<double> sag_points = rotation.rotate(p_sag_points);
|
||||||
|
double sag_value = start_p.z + middle_span * height / span - middle_z;
|
||||||
|
return new Tuple<Matrix<double>, double>(sag_points, sag_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue