Created
June 4, 2011 09:49
-
-
Save vertexclique/1007761 to your computer and use it in GitHub Desktop.
3 nokta alan ve bu noktaların oluşturduğu üçgenin alanı ve açılarını hesaplayan fonksiyon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function threepoints(a,b,c) | |
if( length(a) ~= 3 || length(b) ~= 3 || length(c) ~= 3 ) | |
error('invalid points. points are like (x,y,z)'); | |
end; | |
v1 = b - a; | |
v2 = c - a; | |
v3 = b - c; | |
area = 0.5 * norm(cross(v1,v2)); | |
disp('Area:'); | |
disp(area); | |
a1 = angle(v1,v2); | |
if( a1 > 180) | |
a1 = 180 - a1; | |
end; | |
a2 = angle(v1,v3); | |
if( a1 > 180) | |
a2 = 180 - a1; | |
end; | |
a3 = 180 - (a1+a2); | |
disp('Angles:'); | |
disp(a1); | |
disp(a2); | |
disp(a3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment