I want to gather points in triangle and stokes

1 次查看(过去 30 天)
hello
*I have an array of 80 points
*want to gather points in triangle and the result stored in an array:
  • %angle
*A1 = atan2 (abs ((x2-x1) * (y3-y1) - (x3-x1) * (y2-y1)), ... (x2-x1) * (x3-x1) + (y2-y1) * (y3-y1));
*A2= atan2 (abs ((x1-x2) * (y3-y2) - (x3-x2) * (y1-y2)), ... (x1-x2) * (x3-x2) + (y1-y2) * (y3-y2));
*A3=...
  • %Distance:
  • d1 = norme (P2-P1);
  • d2 = norme (P3-P1);
  • d3 = norme (P3-P2);
*%
*I think 3 loop For
  1 个评论
Roger Stafford
Roger Stafford 2014-3-23
编辑:Roger Stafford 2014-3-23
I understand that you have correctly computed the inner angles and side lengths of a triangle from the coordinates of its three vertices. However, that is where my understanding ends. I am unable to extract a meaningful question from the wording "I want to gather points in triangle and stokes." Could you please elaborate on that? My crystal ball is rather cloudy this morning.

请先登录,再进行评论。

采纳的回答

Roger Stafford
Roger Stafford 2014-3-23
@bil bbil: After consulting your prior question #122689, "how to store all the results in a table with index", it would appear that the triangle calculations are only an incidental part of your inquiry. What you seem to want to do is to store 80!/3!/77! = 82160 sets of results, each set consisting of perhaps nine quantities, in some kind of "table". That is one set for each possible combination of three different points as vertices of a triangle.
It is easy to fill a two-dimensional array with such results. It would have 82160 rows and, say, 9 columns. Your three nested for-loops can be used for this purpose.
T = zeros(82160,9); % <-- This is the big "table" array
k = 0; % k will be its row index
for i1 = 1:78
for i2 = i1+1:79
for i3 = i2+1:80
k = k + 1;
% Compute angles & sides for triangle indexed with i1, i2, and i3
T(k,:) = [i1,i2,i3,d1,d2,d3,A1,A2,A3]; % Store them in k-th row
end
end
end
That's the easy part. What you need in addition to this is some magic function that you can hand a set of indices i1, i2, i3, and access the corresponding row, k, in T. Of course the 'find' function could be used for that purpose, but it would be painfully slow for an array this large. There is a much faster way of deriving the proper row number, k, given i1, i2, & i3, but since all this is mere conjecture on my part, I will hold off constructing that "faster" function until you state definitely that this is indeed what you were really asking for in this question.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by