Page 1 of 1

[SOLVED] converting java code to php

Posted: Mon Oct 24, 2005 11:34 am
by FREESTYLER
i need to convert this java into php
not asking anyone to do it for me just start me off, so if anyone knows java and php wanna lend me a hand?

Code: Select all

package com.satfinder;

/**
 *
 * @author Administrator
 */
         public class Complex {
             private double x;
             private double y;
             
             public Complex(double x,double y) {
                 this.x = x;
                 this.y = y;
             }
             
             public double x() {
                 return x;
             }
             
             public double y() {
                 return y;
             }
         }

Code: Select all

public class satFinder {
    
    /** Creates a new instance of satFinder */
    public satFinder() {
    }
    
    final double toDeg = 180.0/Math.PI;
    final double toRad = Math.PI/180.0;
    
    /*
     *
     * ComputePos(input: (earth) lat (deg), lng (deg),
     * (satellite) satlng (deg),
     *
     * output: Complex(x = az true (deg), y = el (deg))
     *
     * az format: North = 0, East = 90, South = 180, West = 270
     * el format: Horizontal 0, Vertical 90
     *
     */
    
    public Complex computePos(double lat, double lng, double satLng) {
        double dlngr = (lng-satLng) * toRad;
        
        double az = Math.atan2(Math.sin(lat * toRad),Math.tan(dlngr)) * toDeg;
        az = (270.0 - az) / 360.0;
        az = az - Math.floor(az);
        az *= 360.0;
        
        double r1=6.6107; // ratio synchronous orbit/earth radius
        double clng = Math.cos(dlngr);
        double clat = Math.cos(lat * toRad);
        double v1=r1*clat*clng-1.0;
        double v2=r1*Math.sqrt(1-clat*clat*clng*clng);
        double el = Math.atan2(v1,v2) * toDeg;
        return new Complex(az,el);
    }
    
    /*
     *
     * ComputeSkew(input: (earth) lat (deg), lng (deg),
     * (satellite) satlng (deg),
     *
     * output: double skew (deg)
     *
     */
    
    private double computeSkew(double lat, double lng, double satLng) {
        double dlngr = (satLng-lng) * toRad;
        return (Math.atan2(Math.tan(lat * toRad),Math.sin(dlngr)) * toDeg) - 90.0;
    }
    
}
Thanks Guys

Re: converting java code to php

Posted: Mon Oct 24, 2005 12:14 pm
by timvw

Posted: Tue Oct 25, 2005 9:49 am
by FREESTYLER
had no luck, had a look at the links, thanks for that
anyone got another hand?

Posted: Tue Oct 25, 2005 1:46 pm
by timvw
What have you done so far? And where are you having problems? I don't really see where there could be a problem (apart from the package statement) so i think we can guide you through it...