使用方程式和/或向量在3d空间中绘制2d平面图 [英] Graphing 2d plane in 3d space using equation and/or vectors
问题描述
我正在尝试为数学项目制作线性回归平面可视化工具.目前,我已经完成了数学部分,但不确定如何绘制平面图.我有一个z = C + xD + yE形式的方程,其中C,D和E是已知常数.如何使用这些信息绘制平面图?谢谢.
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.
github页面: https://saxocellphone.github.io/LAProject/
github page: https://saxocellphone.github.io/LAProject/
推荐答案
我看到您的问题不是数学问题,而是三个问题, 正如WestLangley在他的评论中指出的那样,您可以进行旋转等操作,或者创建一个简单的三角形,这是最简单的方法
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
因为您有平面的方程式,所以请创建3个点以形成三角形
since you have your equation for the plane create 3 points to form a triangle
// 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
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
这篇关于使用方程式和/或向量在3d空间中绘制2d平面图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!