help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recursion


From: Thomas D. Dean
Subject: Recursion
Date: Mon, 6 Mar 2017 19:06:21 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

I have an application that is called with two points and returns the distance between the points and a mid point. One example returns a distance of 5474. My function is not linear. But, a more simple example illustrates my problem.

function [dist, mid] = gc(p1,p2)
  p3 = p2 - p1;
  dist = sqrt(p3*p3');
  mid = (p1 + p2) ./ 2;
endfunction;

[distance, midpoint] = gc(P1,P2)
while distance > 300
  [distance, midpoint] = gc(P1,midpoint)
endwhile;

This gives me 7 points.  But, I want all the points from
P1, midpoint1, midpoint2, ..., P2

I could recurse, call the first time.
recurse on each half, p1, m1 and m1,p2

How do I do this and get all the points in order?

Tom Dean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]