Cody

# Problem 637. Volume of a Parallelepiped

Solution 1836973

Submitted on 4 Jun 2019 by John Simpson
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
vectors=[1 0 0;0 1 0;0 0 1]; % Unity Cube V=1; assert(isequal(Parallelepiped_volume(vectors),V))

V1 = 1 0 0 V2 = 0 -1 0 a = 1 b = 1 H = 1 dot_product = 0 h = 1 V = 1

2   Pass
vectors=[2 0 0;0 2 0;0 0 2]; % 2x2x2 Cube V=8; assert(isequal(Parallelepiped_volume(vectors),V))

V1 = 2 0 0 V2 = 0 -2 0 a = 2 b = 2 H = 2 dot_product = 0 h = 2 V = 8

3   Pass
vectors=[2 0 0;0 2 0;1 0 1]; % Slanted one side 45 degrees, half h V=4; assert(isequal(Parallelepiped_volume(vectors),V))

V1 = 2 0 0 V2 = 0 -2 0 a = 2 b = 2 H = 1 dot_product = 0 h = 2 V = 4

4   Pass
vectors=[2^0.5 2^0.5 0;-2^0.5 2^0.5 0;0 0 2]; % Rot 45, V=8; assert(V-.001<Parallelepiped_volume(vectors) && Parallelepiped_volume(vectors)<V+.001)

V1 = 2.8284 0 0 V2 = 0 0 0 a = 2.8284 b = 0 H = 2 dot_product = 0 h = 2.8284 V = 8.0000 V1 = 2.8284 0 0 V2 = 0 0 0 a = 2.8284 b = 0 H = 2 dot_product = 0 h = 2.8284 V = 8.0000

5   Pass
vectors=[2^0.5 2^0.5 0;-2^0.5 2^0.5 0;0 1 1]; % Rot 45, Slant 45, h/2 V=4; assert(V-.001<Parallelepiped_volume(vectors) && Parallelepiped_volume(vectors)<V+.001)

V1 = 2.8284 0 0 V2 = 0 0 0 a = 2.8284 b = 0 H = 1 dot_product = 0 h = 2.8284 V = 4.0000 V1 = 2.8284 0 0 V2 = 0 0 0 a = 2.8284 b = 0 H = 1 dot_product = 0 h = 2.8284 V = 4.0000

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!