Skip to content Skip to sidebar Skip to footer

Graphing 2d Plane In 3d Space Using Equation And/or Vectors

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 eq

Solution 1:

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

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


Solution 2:

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

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

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


Post a Comment for "Graphing 2d Plane In 3d Space Using Equation And/or Vectors"