how to reuse a previous function

Im not sure how to recall the last function i did in a new one. (LINE 7)


double azimuth(struct place * a,struct place * b){
(a->lon)*(PI/180.0);
(b->lon)*(PI/180.0);
double C,c,d,azimuth;
C=b-a;
d=(90-a->lat)*(PI/180.0);
c= IM TRYING TO MAKE THIS EQUAL THE LAST FUNCTION I DID
azimuth= sin(C) * sin(d)/sin(c);
return azimuth;
}


ie.
lets say

function A
it outputs D

function B
its operation is 5- D
how do i recall functions A results?

(the previous function im trying to reuse)
double distance_between(struct place * a, struct place * b){

double theta1, phi1, theta2, phi2, dot, dist1, dist2, gamma;
theta1=360-a->lat*(PI/180.0);
phi1=90-a->lon*(PI/180.0);

double x1,y1,z1,x2,y2,z2;
x1=rho*sin(phi1)*cos(theta1);
y1=rho*sin(phi1)*sin(theta1);
z1=rho*cos(phi1);

theta2=(360-b->lat)*(PI/180.0);
phi2=(90-b->lon)*(PI/180.0);

x2=rho*sin(phi2)*cos(theta2);
y2=rho*sin(phi2)*sin(theta2);
z2=rho*cos(phi2);

dot=x1*x2+y1*y2+z1*z2;
dist1=sqrt(x1*x1+y1*y1+z1*z1);
dist2=sqrt(x2*x2+y2*y2+z2*z2);
gamma=acos(dot/(dist1*dist2));

return gamma*rho;

ANY HELP IS AWESOME
What is it exactly you want to do? Call distance_between() from azimuth()? If that's the case, all you need to do is define distance_between() before azimuth().
Also, I'm saying this without a clear idea of what your code does, but this is a faster way to calculate the distance between two 3D points: sqrt(pow(x1-x0,2)+pow(y1-y0,2)+pow(z1-z0,2));

AND USE [code] TAGS!!
Last edited on
call func A() from func B() then D will be available for other purposes
Topic archived. No new replies allowed.