Hi, I'm trying to find the parallel lines who meets at a certain point in 3D space. This is because my input data set lines from points (x,y,z) and some times they are parallel and i'm using this to my criteria.
I think that i've achieved my purpose by:
– getting the point of concurrence of lines
– getting the opposite point of each line
%if the crossed point is (xn,yn,zn) all lines have that point and i found the other one (xi,yi,zi)
– (xi,yi,zi)-(xn,yn,zn) returns the direction 'from crossed point to opposite point' of each line %used this way because the combinations in which my input data is organized
-then took the direction vector to unitary form.
%By doing this i know that parallel lines in the point will have opposite direction and therefor (a,b,c)=-(-a,-b,-c)
sayed the above, my code problem is the following:
paralela=find(all(repmat(auxnodoop3(j,1:3),nbarrasn,1)==-auxnodoop3,2))
%auxnodoop3 – is the unitary direction vector of each line at the crossed point.
%nbarrasn – is the number of lines reaching the point.
The expression in "paralelas" works fine when the line is also parallel to global X,Y,Z. but fails to identify equals component's vector when they are "free" in the space.
for example, at some point and j=3:
repmat() returns
0.5000 0.8660 0 0.5000 0.8660 0 0.5000 0.8660 0
(-auxnodoop3) returns
0.5000 0.8660 0 -0.8660 -0.5000 0 -0.5000 -0.8660 0
all() returns
0 0 1 0 0 1 0 0 1
but should be
1 1 1 0 0 1 0 0 1
The latters will means that line 3 and 1 are parallel
and if lines relies parallel to one of globals X,Y,Z the code works as follows (j=2):
0 0 -1 0 0 -1 0 0 -1 0 0 -1 0.5000 -0.8660 0 0 0 1.0000 -1.0000 0 0 0 0 -1.0000 0 0 0 1 1 0 0 1 0 1 1 1
Meaning that at some point the second and fourth lines are parallel
———————————
I don't know why this is happening, just state the global axes parallelism because in that cases the code works. But shouldn't by related. Also I tried by changing digits() if there were some possibility… but not. Any help?
Best Answer