LIDAR#

Provides functionality to interact with the LiDAR mod.

LiDAR Replacement#

A LiDAR casts a fan of rays from its part. SpaceCenter.SpaceCenter.raycastDistance(org.javatuples.Triplet<Double,Double,Double>, org.javatuples.Triplet<Double,Double,Double>, SpaceCenter.ReferenceFrame) casts one ray. This example casts 8 rays below the root part of the active vessel:

import krpc.client.Connection;
import krpc.client.services.SpaceCenter;
import krpc.client.services.SpaceCenter.Part;
import krpc.client.services.SpaceCenter.ReferenceFrame;

import org.javatuples.Triplet;


public class RaycastExample {
    public static void main(String[] args) {
        Connection connection = Connection.newInstance("Raycast Example");
        SpaceCenter sc = SpaceCenter.newInstance(connection);
        Part part = sc.getActiveVessel().getParts().getRoot();
        ReferenceFrame frame = part.getReferenceFrame();

        // A fan of 8 rays below the part, 10 degrees apart
        Triplet<Double, Double, Double> origin =
            new Triplet<Double, Double, Double>(0.0, 0.0, 0.0);
        for (int i = 0; i < 8; i++) {
            double angle = Math.toRadians(10 * i - 35);
            Triplet<Double, Double, Double> direction =
                new Triplet<Double, Double, Double>(
                    Math.sin(angle), -Math.cos(angle), 0.0);
            System.out.println(
                sc.raycastDistance(origin, direction, frame));
        }
        connection.close();
    }
}