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

时间:2021-09-13 13:34:08

I'm trying to make a linear regression plane visualization tool for a math project. Currently I have the math parts completed, but I am not sure how to graph the plane. I have a equation in the form of z=C+xD+yE, where C, D, and E are known constants. How do I graph the plane using these information? Thanks.

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

github page: https://saxocellphone.github.io/LAProject/

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

2 个解决方案

#1


0  

 z=C+xD+yE

This equation gives full information about the plane. What else you need to graph (plot, draw?) it? Probably it depends on your graphic software possibilities. Canonical form of given equation:

该等式给出了关于平面的完整信息。你需要绘制什么(绘图,绘图?)它?可能这取决于您的图形软件可能性。给定方程的典型形式:

 xD + yE - z + C = 0

Normal to the plane is (D, E, -1). Distance to the coordinate origin Abs(C)/Sqrt(D^2+E^2+1).

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

Plane intersects coordinate axes at values (-C/D), (-C/E), (C)

平面与坐标轴相交(-C / D),( - C / E),(C)

#2


0  

I see your problem is not with math, but with three, as WestLangley pointed out in his comment you can play with rotations etc. or create a simple triangle which is the easiest way

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

since you have your equation for the plane create 3 points to form a triangle

因为你有你的平面方程式创建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

now form a new geometry as in How to make a custom triangle in three.js

现在形成一个新的几何体,如如何在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 ) ); 

create a simple material and add it to a scene

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

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));

that should get you going, you can add another triangles, or make it larger with choosing points that are further apart

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

#1


0  

 z=C+xD+yE

This equation gives full information about the plane. What else you need to graph (plot, draw?) it? Probably it depends on your graphic software possibilities. Canonical form of given equation:

该等式给出了关于平面的完整信息。你需要绘制什么(绘图,绘图?)它?可能这取决于您的图形软件可能性。给定方程的典型形式:

 xD + yE - z + C = 0

Normal to the plane is (D, E, -1). Distance to the coordinate origin Abs(C)/Sqrt(D^2+E^2+1).

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

Plane intersects coordinate axes at values (-C/D), (-C/E), (C)

平面与坐标轴相交(-C / D),( - C / E),(C)

#2


0  

I see your problem is not with math, but with three, as WestLangley pointed out in his comment you can play with rotations etc. or create a simple triangle which is the easiest way

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

since you have your equation for the plane create 3 points to form a triangle

因为你有你的平面方程式创建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

now form a new geometry as in How to make a custom triangle in three.js

现在形成一个新的几何体,如如何在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 ) ); 

create a simple material and add it to a scene

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

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));

that should get you going, you can add another triangles, or make it larger with choosing points that are further apart

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