| 9 | using namespace LNLib; |
| 10 | |
| 11 | TEST(Test_BezierSurface, All) |
| 12 | { |
| 13 | int degreeU = 2; |
| 14 | int degreeV = 1; |
| 15 | UV uv = UV(0.5, 0.5); |
| 16 | |
| 17 | std::vector<std::vector<XYZ>> controlPoints(degreeU + 1, std::vector<XYZ>(degreeV + 1)); |
| 18 | controlPoints[0][0] = XYZ(1, 1, 0); |
| 19 | controlPoints[1][0] = XYZ(1, 1, 1); |
| 20 | controlPoints[2][0] = XYZ(2, 0, 2); |
| 21 | controlPoints[0][1] = XYZ(-1, 1, 0); |
| 22 | controlPoints[1][1] = XYZ(-1, 1, 1); |
| 23 | controlPoints[2][1] = XYZ(-2, 0, 2); |
| 24 | |
| 25 | LN_BezierSurface<XYZ> bezierSurface; |
| 26 | bezierSurface.DegreeU = degreeU; |
| 27 | bezierSurface.DegreeV = degreeV; |
| 28 | bezierSurface.ControlPoints = controlPoints; |
| 29 | |
| 30 | XYZ result = BezierSurface::GetPointOnSurfaceByDeCasteljau(bezierSurface, uv); |
| 31 | EXPECT_TRUE(result.IsAlmostEqualTo(XYZ(0, 0.75, 1.0))); |
| 32 | |
| 33 | std::vector<std::vector<XYZW>> weightedControlPoints(degreeU + 1, std::vector<XYZW>(degreeV + 1)); |
| 34 | |
| 35 | weightedControlPoints[0][0] = XYZW(1, 1, 0, 1); |
| 36 | weightedControlPoints[1][0] = XYZW(1, 1, 1, 1); |
| 37 | weightedControlPoints[2][0] = XYZW(2, 0, 2, 2); |
| 38 | weightedControlPoints[0][1] = XYZW(-1, 1, 0, 1); |
| 39 | weightedControlPoints[1][1] = XYZW(-1, 1, 1, 1); |
| 40 | weightedControlPoints[2][1] = XYZW(-2, 0, 2, 2); |
| 41 | |
| 42 | LN_BezierSurface<XYZW> bezierSurface1; |
| 43 | bezierSurface1.DegreeU = degreeU; |
| 44 | bezierSurface1.DegreeV = degreeV; |
| 45 | bezierSurface1.ControlPoints = weightedControlPoints; |
| 46 | |
| 47 | XYZW weightedResult = BezierSurface::GetPointOnSurfaceByDeCasteljau(bezierSurface1, uv); |
| 48 | EXPECT_TRUE(weightedResult.ToXYZ(true).IsAlmostEqualTo(XYZ(0, 3.0 / 5, 4.0 / 5))); |
| 49 | } |
nothing calls this directly
no test coverage detected