Example #1
0
Vec3 Bezier::SurfNorm(float px, float py) const
{
	Vec3 tempy[4];
	Vec3 tempx[4];
	Vec3 temp2[4];

	//get splines along x axis
	for (int j = 0; j < 4; ++j)
	{
		tempy[j] = Bernstein(px, points[j]);
	}

	//get splines along y axis
	for (int j = 0; j < 4; ++j)
	{
		for (int i = 0; i < 4; ++i)
		{
			temp2[i] = points[i][j];
		}
		tempx[j] = Bernstein(py, temp2);
	}

	Vec3 tx = BernsteinTangent(px, tempx);
	Vec3 ty = BernsteinTangent(py, tempy);
	Vec3 n = -tx.cross(ty).Normalize();

	return n;
}
Example #2
0
MATHVECTOR<float,3> BEZIER::SurfNorm(float px, float py) const
{
	MATHVECTOR<float,3> temp[4];
	MATHVECTOR<float,3> temp2[4];
	MATHVECTOR<float,3> tempx[4];

	//get splines along x axis
	for (int j = 0; j < 4; j++)
	{
		for (int i = 0; i < 4; i++)
			temp2[i] = points[j][i];
		temp[j] = Bernstein(px, temp2);
	}
	
	//get splines along y axis
	for (int j = 0; j < 4; j++)
	{
		for (int i = 0; i < 4; i++)
			temp2[i] = points[i][j];
		tempx[j] = Bernstein(py, temp2);
	}
	
	return -(BernsteinTangent(px, tempx).cross(BernsteinTangent(py, temp)).Normalize());
}