Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 7 Aug, 2010 17:55:05

Message: 1 of 12

I have two points on a sphere (x1,y1,z1) and (x2,y2,z2) that are vertices of a spherical triangle (I considered a sphere of center (0,0,0) and radius 1).

I need to know the coordinates of the other 3rd vertex of the spherical triangle. I know the three angles of the spherical triangle and also the three edge lengths.

I suppose that, in general, there exist 2 solutions for this problem. I need to know how to determine the solutions available.

Thanks,
Catarina

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Roger Stafford

Date: 8 Aug, 2010 01:19:04

Message: 2 of 12

"Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i3k6lo$34v$1@fred.mathworks.com>...
> I have two points on a sphere (x1,y1,z1) and (x2,y2,z2) that are vertices of a spherical triangle (I considered a sphere of center (0,0,0) and radius 1).
>
> I need to know the coordinates of the other 3rd vertex of the spherical triangle. I know the three angles of the spherical triangle and also the three edge lengths.
>
> I suppose that, in general, there exist 2 solutions for this problem. I need to know how to determine the solutions available.
>
> Thanks,
> Catarina
- - - - - - - - - - - -
  All you need are the two (dihedral) angles at either end of the side (arc) between P1 = [x1,y1,z1] and P2 = [x2,y2,z2], and that is what will be assumed here. Call the angle at the P1 vertex a1 and the one at the P2 vertex a2, both in radians.

 P1 = P1/norm(P1); P2 = P2/norm(P2); % Make sure they're unit vectors
 Q = cross(P1,P2); Q = Q/norm(Q); % Normalize their cross product
 R1 = cross(Q,P1); R2 = cross(P2,Q);
 P3 = cross(R2*sin(a2)-Q*cos(a2),R1*sin(a1)-Q*cos(a1));
 P3 = P3/norm(P3); % Make P3 a unit vector
 P4 = cross(R1*sin(a1)+Q*cos(a1),R2*sin(a2)+Q*cos(a2));
 P4 = P4/norm(P4); % Make P4 a unit vector

As one moves from P1 to P2, the points P3 and P4 are the third vertices assuming the triangle lies to the left or to the right, respectively.

Roger Stafford

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 9 Aug, 2010 13:04:04

Message: 3 of 12

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3l0m8$8f7$1@fred.mathworks.com>...
> "Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i3k6lo$34v$1@fred.mathworks.com>...
> > I have two points on a sphere (x1,y1,z1) and (x2,y2,z2) that are vertices of a spherical triangle (I considered a sphere of center (0,0,0) and radius 1).
> >
> > I need to know the coordinates of the other 3rd vertex of the spherical triangle. I know the three angles of the spherical triangle and also the three edge lengths.
> >
> > I suppose that, in general, there exist 2 solutions for this problem. I need to know how to determine the solutions available.
> >
> > Thanks,
> > Catarina
> - - - - - - - - - - - -
> All you need are the two (dihedral) angles at either end of the side (arc) between P1 = [x1,y1,z1] and P2 = [x2,y2,z2], and that is what will be assumed here. Call the angle at the P1 vertex a1 and the one at the P2 vertex a2, both in radians.
>
> P1 = P1/norm(P1); P2 = P2/norm(P2); % Make sure they're unit vectors
> Q = cross(P1,P2); Q = Q/norm(Q); % Normalize their cross product
> R1 = cross(Q,P1); R2 = cross(P2,Q);
> P3 = cross(R2*sin(a2)-Q*cos(a2),R1*sin(a1)-Q*cos(a1));
> P3 = P3/norm(P3); % Make P3 a unit vector
> P4 = cross(R1*sin(a1)+Q*cos(a1),R2*sin(a2)+Q*cos(a2));
> P4 = P4/norm(P4); % Make P4 a unit vector
>
> As one moves from P1 to P2, the points P3 and P4 are the third vertices assuming the triangle lies to the left or to the right, respectively.
>
> Roger Stafford

Thanks!!
It is possible to create a set of the points inside a spherical triangle? I explain... Suppose that I have already drawn a spherical triangle T1 in the sphere and let S1 be the set of all points of the sphere that lie inside that spherical triangle (excluding the boundary). I will consider another spherical triangle T2 with 2 vertices in common with T1 (the triangles are in adjacent positions). Given your answer, I have two possibilities for T2 (corresponding to your possibilities for the third vertex), although only one is of interest (the one that have no points in the interior of T1 and T2 simultaneously). If I could consider S1 and S2 (this last corresponding to the set of all points of the sphere that lie inside that spherical triangle T2, excluding the boundary), I have the possibility to test the intersection of S1 with S2 and make the choice of the third vertex of the new
triangle on this basis.
It is possible to do that?
Thanks again,
Catarina Avelino

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Roger Stafford

Date: 9 Aug, 2010 18:06:04

Message: 4 of 12

"Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i3ouc4$jve$1@fred.mathworks.com>...
> Thanks!!
> It is possible to create a set of the points inside a spherical triangle? I explain... Suppose that I have already drawn a spherical triangle T1 in the sphere and let S1 be the set of all points of the sphere that lie inside that spherical triangle (excluding the boundary). I will consider another spherical triangle T2 with 2 vertices in common with T1 (the triangles are in adjacent positions). Given your answer, I have two possibilities for T2 (corresponding to your possibilities for the third vertex), although only one is of interest (the one that have no points in the interior of T1 and T2 simultaneously). If I could consider S1 and S2 (this last corresponding to the set of all points of the sphere that lie inside that spherical triangle T2, excluding the boundary), I have the possibility to test the intersection of S1 with S2 and make the choice of the third vertex of the new
> triangle on this basis.
> It is possible to do that?
> Thanks again,
> Catarina Avelino
- - - - - - - - - - -
  In the last paragraph I said "As one moves from P1 to P2, the points P3 and P4 are the third vertices assuming the triangle lies to the left or to the right, respectively." By that I meant that as you move along the arc from P1 to P2, the points to the immediate left side of the arc belong to the triangle P1P2P3 and the points to the immediate right side of the arc belong to triangle P1P2P4. Hence if you used P1 and P2 as common points between two different triangles, to prevent them from having points in common you must select the "P3" type vertex for one of the triangles and the "P4" type for the other triangle. (By "P3 type" or "P4 type" I mean the points created by the algorithm I gave using P1 and P2 which I have called P3 and P4, respectively.)

  However you should realize that this is no guarantee that the two triangles won't overlap. It is easily possible for very large triangles to occupy points in common in spite of taking this precaution. For example, if the "spherical excess" of each triangle (the amount by which the sum of its angle exceeds pi) is greater than 2*pi, then the sum of the areas of the two triangle would be greater than the area of the whole sphere so they would necessarily overlap.

  On the other hand, if you know that both of the angles at P1 and P2 are less than pi for each of the two triangles, you could safely conclude that the above P3/P4 precaution would then prevent them from overlapping, since the triangles would be limited to opposite sides of the great circle plane running through P1P2.

  If you meant something beyond the above when you said "create a set of the points inside a spherical triangle", please let me know.

Roger Stafford

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 9 Aug, 2010 22:50:25

Message: 5 of 12

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3pg2c$o42$1@fred.mathworks.com>...
> "Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i3ouc4$jve$1@fred.mathworks.com>...
> > Thanks!!
> > It is possible to create a set of the points inside a spherical triangle? I explain... Suppose that I have already drawn a spherical triangle T1 in the sphere and let S1 be the set of all points of the sphere that lie inside that spherical triangle (excluding the boundary). I will consider another spherical triangle T2 with 2 vertices in common with T1 (the triangles are in adjacent positions). Given your answer, I have two possibilities for T2 (corresponding to your possibilities for the third vertex), although only one is of interest (the one that have no points in the interior of T1 and T2 simultaneously). If I could consider S1 and S2 (this last corresponding to the set of all points of the sphere that lie inside that spherical triangle T2, excluding the boundary), I have the possibility to test the intersection of S1 with S2 and make the choice of the third vertex of the new
> > triangle on this basis.
> > It is possible to do that?
> > Thanks again,
> > Catarina Avelino
> - - - - - - - - - - -
> In the last paragraph I said "As one moves from P1 to P2, the points P3 and P4 are the third vertices assuming the triangle lies to the left or to the right, respectively." By that I meant that as you move along the arc from P1 to P2, the points to the immediate left side of the arc belong to the triangle P1P2P3 and the points to the immediate right side of the arc belong to triangle P1P2P4. Hence if you used P1 and P2 as common points between two different triangles, to prevent them from having points in common you must select the "P3" type vertex for one of the triangles and the "P4" type for the other triangle. (By "P3 type" or "P4 type" I mean the points created by the algorithm I gave using P1 and P2 which I have called P3 and P4, respectively.)
>
> However you should realize that this is no guarantee that the two triangles won't overlap. It is easily possible for very large triangles to occupy points in common in spite of taking this precaution. For example, if the "spherical excess" of each triangle (the amount by which the sum of its angle exceeds pi) is greater than 2*pi, then the sum of the areas of the two triangle would be greater than the area of the whole sphere so they would necessarily overlap.
>
> On the other hand, if you know that both of the angles at P1 and P2 are less than pi for each of the two triangles, you could safely conclude that the above P3/P4 precaution would then prevent them from overlapping, since the triangles would be limited to opposite sides of the great circle plane running through P1P2.
>
> If you meant something beyond the above when you said "create a set of the points inside a spherical triangle", please let me know.
>
> Roger Stafford

The problem is that I do not know if "the triangle lies to the left or to the right" (I am trying to make a code to decide it, but I not yet realized how). I will try to explain better the idea. Note that in this problem the angles of all spherical triangles are less than pi and the interior of two spherical triangles won't overlap (not including the boundaries of the triangles, that overlap when there are edges in common).
So, suppose that I have drawn a spherical triangle ABC. And now I want to draw another spherical triangle, for example ACD, in adjacent positions (with edge AC in common). With your answer I will have two possibilities for vertex D and consequently two possibilities for the spherical triangle (say ACD1 and ACD2, consonant the triangle lies to the left or to the right). I need to choose the right option, i.e, the one that makes that the interior of the triangles will not overlap.
For this reason I thought to consider three sets S, S1 and S2 corresponding to the set of all points of the sphere that lie inside the spherical triangles ABC, ACD1 and ACD2, respectively, and to test the intersection of S with both S1 and S2. In one case the intersection is empty and in the other case is not empty. The right option will be the triangle that leads to the empty intersection. The question is I do not know how to put this in a matlab code and if it is possible to make that.
Thanks,
Catarina

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Roger Stafford

Date: 10 Aug, 2010 00:04:05

Message: 6 of 12

"Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i3q0nh$5jh$1@fred.mathworks.com>...
> The problem is that I do not know if "the triangle lies to the left or to the right" (I am trying to make a code to decide it, but I not yet realized how). I will try to explain better the idea. Note that in this problem the angles of all spherical triangles are less than pi and the interior of two spherical triangles won't overlap (not including the boundaries of the triangles, that overlap when there are edges in common).
> So, suppose that I have drawn a spherical triangle ABC. And now I want to draw another spherical triangle, for example ACD, in adjacent positions (with edge AC in common). With your answer I will have two possibilities for vertex D and consequently two possibilities for the spherical triangle (say ACD1 and ACD2, consonant the triangle lies to the left or to the right). I need to choose the right option, i.e, the one that makes that the interior of the triangles will not overlap.
> For this reason I thought to consider three sets S, S1 and S2 corresponding to the set of all points of the sphere that lie inside the spherical triangles ABC, ACD1 and ACD2, respectively, and to test the intersection of S with both S1 and S2. In one case the intersection is empty and in the other case is not empty. The right option will be the triangle that leads to the empty intersection. The question is I do not know how to put this in a matlab code and if it is possible to make that.
> Thanks,
> Catarina
- - - - - - - - - - - -
  You have stated that all of your angles in the triangles are less than pi radians. With that understanding, if your triangle has three vertices with coordinates V1 = (x1,y1,z1), V2 = (x2,y2,z2), and V3 = (x3,y3,z3), that satisfy

 det([x1,y1,z1;x2,y2,z2;x3,y3,z3]) > 0

then the vertices V1, V2, V3 will be in counterclockwise order as you move around the triangle in that sequence as viewed from outside the sphere looking inward. If this determinant is negative their order is clockwise.

  To ensure that your ABC triangle does not overlap ACD, you should make the sequence A, C, B opposite in orientation to that of A, C, D. In other words choose D1 or D2 whichever one gives this opposite orientation. As you travel along the arc from A to C, the triangle that is on the left will clearly have a counterclockwise orientation and that on the right a clockwise orientation, so you must make your choice between D1 and D2 accordingly.

  Generating random S points in the interiors of the triangles is definitely not the way to decide this overlapping question! That would make a most unsatisfactory algorithm. You might grow old waiting for your computer to make a proper decision. There are after all infinitely many points to inspect in their interiors. It would make more sense to generate one point known to be in the interior of one triangle and then to ask whether it also lay inside the other triangle. However, that is still far more work than is necessary.

Roger Stafford

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Roger Stafford

Date: 10 Aug, 2010 00:13:04

Message: 7 of 12

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3q51l$3b5$1@fred.mathworks.com>...
> ....... It would make more sense to generate one point known to be in the interior of one triangle and then to ask whether it also lay inside the other triangle. However, that is still far more work than is necessary.
>
> Roger Stafford
- - - - - - - - - -
  Whoops! Cancel those last two sentences that begin with "It would make more sense ....." It was a mental aberration. Just stick to the determinant method.

Roger Stafford

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 10 Aug, 2010 09:27:05

Message: 8 of 12

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3q5ig$5pl$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3q51l$3b5$1@fred.mathworks.com>...
> > ....... It would make more sense to generate one point known to be in the interior of one triangle and then to ask whether it also lay inside the other triangle. However, that is still far more work than is necessary.
> >
> > Roger Stafford
> - - - - - - - - - -
> Whoops! Cancel those last two sentences that begin with "It would make more sense ....." It was a mental aberration. Just stick to the determinant method.
>
> Roger Stafford

Thank you very much for your help!
Catarina

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 23 Oct, 2010 18:43:04

Message: 9 of 12

Could you please send me your email as <ellieandrogerxyzzy@mindspring.com.invalid> (removing "xyzzy" and ".invalid") did not worked. I received an error message.
Thanks,
Catarina Avelino

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Roger Stafford

Date: 23 Oct, 2010 20:13:06

Message: 10 of 12

"Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i9vabo$oof$1@fred.mathworks.com>...
> Could you please send me your email as <ellieandrogerxyzzy@mindspring.com.invalid> (removing "xyzzy" and ".invalid") did not worked. I received an error message.
> Thanks,
> Catarina Avelino
- - - - - - - - -
  I prefer not to do that, Catarina. Please ask your questions in this newsgroup and I or others will attempt to answer them. If the questions pertain to a different area, it would be advisable to start a new thread.

  Did that determinant criterion prove to be useful to you?

Roger Stafford

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 23 Oct, 2010 22:55:04

Message: 11 of 12

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i9vfki$oo8$1@fred.mathworks.com>...
> "Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i9vabo$oof$1@fred.mathworks.com>...
> > Could you please send me your email as <ellieandrogerxyzzy@mindspring.com.invalid> (removing "xyzzy" and ".invalid") did not worked. I received an error message.
> > Thanks,
> > Catarina Avelino
> - - - - - - - - -
> I prefer not to do that, Catarina. Please ask your questions in this newsgroup and I or others will attempt to answer them. If the questions pertain to a different area, it would be advisable to start a new thread.
>
> Did that determinant criterion prove to be useful to you?
>
> Roger Stafford

Ok, no problem! Is not about to ask a question. But thanks any way!
Yes, the determinant criterion was very useful for me. It helped me to develop the matlab code I needed.
Catarina

Subject: Calculate the coordinates of the 3rd vertex of a spherical triangle knowing the other 2 vertices, angles and edge lengths

From: Catarina Avelino

Date: 23 Oct, 2010 22:56:04

Message: 12 of 12

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i9vfki$oo8$1@fred.mathworks.com>...
> "Catarina Avelino" <cavelino@mat.uc.pt> wrote in message <i9vabo$oof$1@fred.mathworks.com>...
> > Could you please send me your email as <ellieandrogerxyzzy@mindspring.com.invalid> (removing "xyzzy" and ".invalid") did not worked. I received an error message.
> > Thanks,
> > Catarina Avelino
> - - - - - - - - -
> I prefer not to do that, Catarina. Please ask your questions in this newsgroup and I or others will attempt to answer them. If the questions pertain to a different area, it would be advisable to start a new thread.
>
> Did that determinant criterion prove to be useful to you?
>
> Roger Stafford

Ok, no problem! Is not about to ask a question. But thanks any way!
Yes, the determinant criterion was very useful for me. It helped me to develop the matlab code I needed.
Catarina

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us