使用方程和/或向量在 3d 空间中绘制 2d 平面 [英] Graphing 2d plane in 3d space using equation and/or vectors

查看:29
本文介绍了使用方程和/或向量在 3d 空间中绘制 2d 平面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为数学项目制作线性回归平面可视化工具.目前我已经完成了数学部分,但我不确定如何绘制平面图.我有一个形式为 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/

推荐答案

我看你的问题不是数学,而是三个,正如 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

现在形成一个新的几何体,如如何制作Three.js中的自定义三角形

now form a new geometry as in 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 ) ); 

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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆