Filter löschen
Filter löschen

Inscribed n-gon of unit circle.

3 Ansichten (letzte 30 Tage)
Jim Oste
Jim Oste am 10 Feb. 2015
Beantwortet: Image Analyst am 10 Feb. 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?

Akzeptierte Antwort

Image Analyst
Image Analyst am 10 Feb. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Computational Geometry finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by