使用等式和/或向量在{3}空间中绘制2d平面

时间:2016-05-07 15:26:21

标签: javascript math 3d three.js

我正在尝试为数学项目制作线性回归平面可视化工具。目前我已完成数学部分,但我不确定如何绘制飞机图形。我有一个z = C + xD + yE形式的方程式,其中C,D和E是已知的常数。如何使用这些信息绘制飞机图形?感谢。

github页面:https://saxocellphone.github.io/LAProject/

2 个答案:

答案 0 :(得分:0)

 z=C+xD+yE

此等式提供有关飞机的完整信息。你需要绘制什么(绘图,绘图?)它?可能这取决于您的图形软件可能性。 给定方程的典型形式:

 xD + yE - z + C = 0

飞机的法线为(D, E, -1)。距坐标原点Abs(C)/Sqrt(D^2+E^2+1)的距离。

平面与值(-C/D), (-C/E), (C)

的坐标轴相交

答案 1 :(得分:0)

我看到你的问题不是数学,而是三, 正如WestLangley在他的评论中指出的那样,你可以玩旋转等,或创建一个简单的三角形,这是最简单的方法

因为你有你的平面方程创造3个点来形成一个三角形

// z=C+xD+yE
// i assume here that the plane is not aligned with any axis 
// and does not pass through the origin, otherwise choose the points in another way
var point1 = new THREE.Vector3(-C/D,0,0);//x axis intersection
var point2 = new THREE.Vector3(0,-C/E,0);//y axis intersection
var point3 = new THREE.Vector3(0,0,C);//z axis intersection

现在形成一个新的几何体,如How to make a custom triangle in three.js

var geom = new THREE.Geometry(); 
geom.vertices.push(point1);// adding vertices to geometry
geom.vertices.push(point2);
geom.vertices.push(point3);
// telling geometry that vertices 0,1,2 form a face = triangle
geom.faces.push( new THREE.Face3( 0, 1, 2 ) ); 

创建一个简单的材质并将其添加到场景

var material = new THREE.MeshBasicMaterial({
    color: 0xff0000, // RGB hex color for material
    side: THREE.DoubleSide // do not hide object when viewing from back
});
scene.add(new THREE.Mesh(geometry,material));

应该让你去,你可以添加另一个三角形,或者通过选择更远的点来增大它们

相关问题