Effacer les filtres
Effacer les filtres

Inscribed n-gon of unit circle.

3 vues (au cours des 30 derniers jours)
Jim Oste
Jim Oste le 10 Fév 2015
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?

Réponse acceptée

Image Analyst
Image Analyst le 10 Fév 2015
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.

Plus de réponses (0)

Catégories

En savoir plus sur Computational Geometry dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by