Inscribed n-gon of unit circle.

3 次查看(过去 30 天)
I was given the following code to determine the length of a polygonal curve
function [ len ] = ost_len( x,y )
%Length of polygonal curve.
% This function computes the length of the polygonal curve whos ith
% ith vertex has Cartesian coordinates x(i) and y(i)
x = rand(1, 5);
y = rand(1, 5);
dx = abs([diff(x), x(end)-x(1)]);
dy = abs([diff(y), y(end)-y(1)]);
dist = sqrt(dx.^2 + dy.^2);
len = sum(dist);
disp(len)
end
I am now somehow supposed to calculate the length of an inscribed n-gon for a unit circle for n=2^i, where i = 2,3,...,8.
Would the function given help me or do I need to alter it?

采纳的回答

Image Analyst
Image Analyst 2015-2-10
Well obviously for an inscribed n-gon, you wouldn't want to use random x and y so get rid of those lines. Those were just sample data that were created. You have to replace it with points on the unit circle. I assume you know how to use sin() and cos() so this will be no problem for you.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computational Geometry 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by