Could someone please check this plane definition

closed account (2NywAqkS)
I'm not very good at math, but from what I've gathered from the internet this is how I could define a plane from three points (in 3D).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
struct vertex3
{
	double x, y, z;
	vertex3();
	vertex3(double x, double y, double z)
	{
		this->x = x, this->y = y, this->z = z;
	}
};

double dotProduct(vertex3 a, vertex3 b)
{
	return  a.x*b.x + a.y*b.y + a.z*b.z;
}

vertex3 crossProduct(vertex3 a, vertex3 b)
{
    vertex3 vector;
    vector.x = (a.y*b.z)-(b.y*a.z);
    vector.y = -(a.x*b.z)+(b.x*a.z);
    vector.z = (a.x*b.y)-(a.y*b.x);
    return vector;
}

struct plane
{
	vertex3 n; // a, b and c
	double d;
	// Define plane from three points (triangle)
	plane(vertex3 a, vertex3 b, vertex3 c)
	{
		vertex3 u(b.x - a.x, b.y - a.y, b.z - a.z);
		vertex3 v(c.x - a.x, c.y - a.y, c.z - a.z);
		n = crossProduct(u, v);
		d = dotProduct(n, a);
	}
};


Thanks,
Rowan.
You're not defining the plane, but you have the parts you need. Plane equation is a(x - x0) + b(y - y0) + c(z - z0) = 0 where <a,b,c> is the normal vector to the plane and (x0, y0, z0) is a point on the plane.
closed account (2NywAqkS)
if (x0, y0, z0) is a point on the plane what's (x, y, z)?
^ the coordinates of the point that you are testing to see if it is in the plane.

@naraku9333:
a(x - x0) + b(y - y0) + c(z - z0) = 0
ax + by + cz = ax0 + by0 + cz0
ax + by + cz = d

or simply n_j x_j = d
Last edited on
Topic archived. No new replies allowed.