How to check the degree of parallelism

9 views (last 30 days)
M
M on 16 Jul 2023
Edited: M on 18 Aug 2023
How to check the degree parallelism of the result of intersecting planes in affine space (give the percentage of the parallelism) with tolerance to get an indicator of how much they are in the same orientation in the following case?
But from mathematical point of view not only commands.
The two objects that I want to check their parallelism are the intersecting object between plane 1 and plane 2 AND the intersected object between plane 1 and plane 3
the direction of two objects are expressed in terms of directions 1 and directions2
Note: the objects are intersecting in some points but I want an indicator that these two objects have almost the same directions!
P1=[396218721.065513 -205153846.153846 0 0 0 0
-205153846.153846 396218721.065513 -205153846.153846 0 0 0
0 -205153846.153846 396218721.065513 -205153846.153846 0 0
0 0 -205153846.153846 396218721.065513 -205153846.153846 0
0 0 0 -205153846.153846 396218721.065513 -205153846.153846
0 0 0 0 -205153846.153846 198109360.532757];
P2=[239737786.836378 -41030769.2307692 0 0 0 0
-41030769.2307692 239737786.836378 -205153846.153846 0 0 0
0 -205153846.153846 403860863.759455 -205153846.153846 0 0
0 0 -205153846.153846 403860863.759455 -205153846.153846 0
0 0 0 -205153846.153846 403860863.759455 -205153846.153846
0 0 0 0 -205153846.153846 201930431.879727];
Aeq1=null([P1(2:6,:)-P1(1,:)])';
Aeq2=null([P2(2:6,:)-P2(1,:)])';
beq1=Aeq1*P1(1,:)';
beq2=Aeq2*P2(1,:)';
Aeq=[Aeq1;Aeq2];
beq=[beq1;beq2];
assert( rank([Aeq,beq])==rank(Aeq) , 'Hyperplanes do not intersect')
origin1 = pinv(Aeq)*beq
origin1 = 6×1
1.0e+04 * -6.8832 8.1890 2.5987 -1.8223 -4.6515 -5.6221
directions1 = null(Aeq)
directions1 = 6×4
-0.1750 -0.3776 -0.5066 -0.5507 -0.5308 -0.2946 -0.1425 -0.0902 0.8120 -0.1800 -0.1745 -0.1725 -0.1258 0.8234 -0.2087 -0.2196 -0.0857 -0.1739 0.7699 -0.2493 -0.0718 -0.1730 -0.2374 0.7406
P3=[376176938.886082 -184638461.538462 0 0 0 0
-184638461.538462 376176938.886082 -205153846.153846 0 0 0
0 -205153846.153846 396692323.501467 -205153846.153846 0 0
0 0 -205153846.153846 396692323.501467 -205153846.153846 0
0 0 0 -205153846.153846 396692323.501467 -205153846.153846
0 0 0 0 -205153846.153846 198346161.750733];
Aeq1=null([P1(2:6,:)-P1(1,:)])';
Aeq3=null([P3(2:6,:)-P3(1,:)])';
beq1=Aeq1*P1(1,:)';
beq3=Aeq3*P3(1,:)';
Aeq22=[Aeq1;Aeq3];
beq22=[beq1;beq3];
assert( rank([Aeq22,beq22])==rank(Aeq) , 'Hyperplanes do not intersect')
origin2 = pinv(Aeq22)*beq22
origin2 = 6×1
1.0e+06 * -0.9104 1.3951 0.6253 -0.0096 -0.4236 -0.5618
directions2 = null(Aeq22)
directions2 = 6×4
-0.1807 -0.3839 -0.5148 -0.5587 -0.5343 -0.2872 -0.1249 -0.0708 0.8089 -0.1800 -0.1720 -0.1694 -0.1260 0.8228 -0.2098 -0.2208 -0.0831 -0.1746 0.7665 -0.2533 -0.0688 -0.1739 -0.2416 0.7357
  4 Comments
Walter Roberson
Walter Roberson on 16 Jul 2023
@M sorry, my relevant classes were pretty much 40 years ago.
Bruno Luong
Bruno Luong on 22 Jul 2023
This is buggy
assert( rank([Aeq22,beq22])==rank(Aeq) , 'Hyperplanes do not intersect')
The correct should be (Aeq replaced by Aeq22)
assert( rank([Aeq22,beq22])==rank(Aeq22) , 'Hyperplanes do not intersect')

Sign in to comment.

Answers (3)

Torsten
Torsten on 16 Jul 2023
The intersection of P1 and P2 is given by
x = origin1 + directions1*lambda
the intersection of P1 and P3 is given by
x = origin2 + directions2*mu
with arbitrary 4x1 vectors lambda and mu.
If the system
origin1 + directions1*lambda = origin2 + directions2*mu
has a solution for (lambda,mu), the two intersections cannot be parallel.
Let's try:
P1=[396218721.065513 -205153846.153846 0 0 0 0
-205153846.153846 396218721.065513 -205153846.153846 0 0 0
0 -205153846.153846 396218721.065513 -205153846.153846 0 0
0 0 -205153846.153846 396218721.065513 -205153846.153846 0
0 0 0 -205153846.153846 396218721.065513 -205153846.153846
0 0 0 0 -205153846.153846 198109360.532757];
P2=[239737786.836378 -41030769.2307692 0 0 0 0
-41030769.2307692 239737786.836378 -205153846.153846 0 0 0
0 -205153846.153846 403860863.759455 -205153846.153846 0 0
0 0 -205153846.153846 403860863.759455 -205153846.153846 0
0 0 0 -205153846.153846 403860863.759455 -205153846.153846
0 0 0 0 -205153846.153846 201930431.879727];
Aeq1=null([P1(2:6,:)-P1(1,:)])';
Aeq2=null([P2(2:6,:)-P2(1,:)])';
beq1=Aeq1*P1(1,:)';
beq2=Aeq2*P2(1,:)';
Aeq=[Aeq1;Aeq2];
beq=[beq1;beq2];
assert( rank([Aeq,beq])==rank(Aeq) , 'Hyperplanes do not intersect')
origin1 = pinv(Aeq)*beq
origin1 = 6×1
1.0e+04 * -6.8832 8.1890 2.5987 -1.8223 -4.6515 -5.6221
directions1 = null(Aeq)
directions1 = 6×4
-0.1750 -0.3776 -0.5066 -0.5507 -0.5308 -0.2946 -0.1425 -0.0902 0.8120 -0.1800 -0.1745 -0.1725 -0.1258 0.8234 -0.2087 -0.2196 -0.0857 -0.1739 0.7699 -0.2493 -0.0718 -0.1730 -0.2374 0.7406
P3=[376176938.886082 -184638461.538462 0 0 0 0
-184638461.538462 376176938.886082 -205153846.153846 0 0 0
0 -205153846.153846 396692323.501467 -205153846.153846 0 0
0 0 -205153846.153846 396692323.501467 -205153846.153846 0
0 0 0 -205153846.153846 396692323.501467 -205153846.153846
0 0 0 0 -205153846.153846 198346161.750733];
Aeq1=null([P1(2:6,:)-P1(1,:)])';
Aeq3=null([P3(2:6,:)-P3(1,:)])';
beq1=Aeq1*P1(1,:)';
beq3=Aeq3*P3(1,:)';
Aeq22=[Aeq1;Aeq3];
beq22=[beq1;beq3];
assert( rank([Aeq22,beq22])==rank(Aeq) , 'Hyperplanes do not intersect')
origin2 = pinv(Aeq22)*beq22
origin2 = 6×1
1.0e+06 * -0.9104 1.3951 0.6253 -0.0096 -0.4236 -0.5618
directions2 = null(Aeq22)
directions2 = 6×4
-0.1807 -0.3839 -0.5148 -0.5587 -0.5343 -0.2872 -0.1249 -0.0708 0.8089 -0.1800 -0.1720 -0.1694 -0.1260 0.8228 -0.2098 -0.2208 -0.0831 -0.1746 0.7665 -0.2533 -0.0688 -0.1739 -0.2416 0.7357
M = [-directions1, directions2];
rhs = origin1 - origin2;
lambdamu = pinv(M)*rhs;
lambda = lambdamu(1:4);
mu = lambdamu(5:8);
% Check that intersecting point lies in both affine spaces
intersecting_point_1 = origin1 + directions1*lambda
intersecting_point_1 = 6×1
1.0e+07 * 4.7633 1.1871 2.0525 0.2404 -1.6477 -1.9003
intersecting_point_2 = origin2 + directions2*mu
intersecting_point_2 = 6×1
1.0e+07 * 4.7633 1.1871 2.0525 0.2404 -1.6477 -1.9003
  84 Comments
Bruno Luong
Bruno Luong on 18 Aug 2023
Edited: Bruno Luong on 18 Aug 2023
@M "but it didn't meet my requirement!"
This requirement is honestly is NOT in your original question which is for the record about mesuring degree of parallelism of two affine spaces (see your code).
M
M on 18 Aug 2023
Edited: M on 18 Aug 2023
@Torsten I liked your metaphor :) , but I think sometimes you can't tell all the people that you have diabetes...
Btw I am still studying the paper that you recommended to me.. Thanks

Sign in to comment.


Sahaj
Sahaj on 16 Jul 2023
Hi M.
You can use the following code to give the percentage of parallelism while including tolerance in determining if the lines can be considered parallel.
% Define the tolerance threshold
tolerance = 0.99; % Adjust this value according to your desired tolerance
% Determine the direction vectors
directions1 = null(Aeq);
directions2 = null(Aeq22);
% Compute the angle between the direction vectors
cosine_angle = dot(directions1(:, 1), directions2(:, 1)) / (norm(directions1(:, 1)) * norm(directions2(:, 1)));
angle_rad = acos(cosine_angle);
% Calculate the percentage of parallelism
angle_deg = rad2deg(angle_rad);
perpendicular_angle_deg = 90 - angle_deg;
percentage_parallelism = (1 - perpendicular_angle_deg / 90) * 100;
% Check if the lines are parallel based on the tolerance threshold
if cosine_angle >= tolerance
fprintf('Lines are parallel with a percentage of parallelism: %.2f%%\n', percentage_parallelism);
else
fprintf('Lines are not parallel.\n');
end
You can repeat the above steps to check the parallelism between plane1 and plane3.
  1 Comment
M
M on 16 Jul 2023
Edited: M on 16 Jul 2023
@Sahaj, the 'directions' is a full matrix which is an indication of direction of the intersection between two hyperplane! we can't take a vector from it to decide!

Sign in to comment.


Bruno Luong
Bruno Luong on 20 Jul 2023
I'm not sure, but it looks like you might take a look at subspace command
  1 Comment
Bruno Luong
Bruno Luong on 22 Jul 2023
Edited: Bruno Luong on 22 Jul 2023
Tha angle between 2 afine spaces is 0.0303 rad or 1.7376 degrees
P1=[396218721.065513 -205153846.153846 0 0 0 0
-205153846.153846 396218721.065513 -205153846.153846 0 0 0
0 -205153846.153846 396218721.065513 -205153846.153846 0 0
0 0 -205153846.153846 396218721.065513 -205153846.153846 0
0 0 0 -205153846.153846 396218721.065513 -205153846.153846
0 0 0 0 -205153846.153846 198109360.532757];
P2=[239737786.836378 -41030769.2307692 0 0 0 0
-41030769.2307692 239737786.836378 -205153846.153846 0 0 0
0 -205153846.153846 403860863.759455 -205153846.153846 0 0
0 0 -205153846.153846 403860863.759455 -205153846.153846 0
0 0 0 -205153846.153846 403860863.759455 -205153846.153846
0 0 0 0 -205153846.153846 201930431.879727];
Aeq1=null([P1(2:6,:)-P1(1,:)])';
Aeq2=null([P2(2:6,:)-P2(1,:)])';
beq1=Aeq1*P1(1,:)';
beq2=Aeq2*P2(1,:)';
Aeq=[Aeq1;Aeq2];
beq=[beq1;beq2];
assert( rank([Aeq,beq])==rank(Aeq) , 'Hyperplanes do not intersect')
origin1 = pinv(Aeq)*beq;
directions1 = null(Aeq)
directions1 = 6×4
-0.1750 -0.3776 -0.5066 -0.5507 -0.5308 -0.2946 -0.1425 -0.0902 0.8120 -0.1800 -0.1745 -0.1725 -0.1258 0.8234 -0.2087 -0.2196 -0.0857 -0.1739 0.7699 -0.2493 -0.0718 -0.1730 -0.2374 0.7406
P3=[376176938.886082 -184638461.538462 0 0 0 0
-184638461.538462 376176938.886082 -205153846.153846 0 0 0
0 -205153846.153846 396692323.501467 -205153846.153846 0 0
0 0 -205153846.153846 396692323.501467 -205153846.153846 0
0 0 0 -205153846.153846 396692323.501467 -205153846.153846
0 0 0 0 -205153846.153846 198346161.750733];
Aeq1=null([P1(2:6,:)-P1(1,:)])';
Aeq3=null([P3(2:6,:)-P3(1,:)])';
beq1=Aeq1*P1(1,:)';
beq3=Aeq3*P3(1,:)';
Aeq22=[Aeq1;Aeq3];
beq22=[beq1;beq3];
assert( rank([Aeq22,beq22])==rank(Aeq22) , 'Hyperplanes do not intersect')
origin2 = pinv(Aeq22)*beq22;
directions2 = null(Aeq22)
directions2 = 6×4
-0.1807 -0.3839 -0.5148 -0.5587 -0.5343 -0.2872 -0.1249 -0.0708 0.8089 -0.1800 -0.1720 -0.1694 -0.1260 0.8228 -0.2098 -0.2208 -0.0831 -0.1746 0.7665 -0.2533 -0.0688 -0.1739 -0.2416 0.7357
The angle between directions1 and directions2 (origins are irrelevant)
theta = subspace(directions1, directions2)
theta = 0.0303
theta_degree = rad2deg(theta)
theta_degree = 1.7376
This is the same as the angle between the respective orthogonal subspaces
rad2deg(subspace(Aeq',Aeq22'))
ans = 1.7376

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!