Java interpolate interpolate(int a, int b, int theta, int reciprocal)

Here you can find the source of interpolate(int a, int b, int theta, int reciprocal)

Description

Interpolates two smooth noise values.

License

Open Source License

Parameter

Parameter Description
a The first smooth noise value.
b The second smooth noise value.
theta The angle.
reciprocal The frequency reciprocal.

Return

The interpolated value.

Declaration

private static int interpolate(int a, int b, int theta, int reciprocal) 

Method Source Code

//package com.java2s;

public class Main {
    /**// w w w . j  ava 2  s.c o m
     * The cosine table used for interpolation.
     */
    private static final int[] COSINE = new int[2048];

    /**
     * Interpolates two smooth noise values.
     *
     * @param a The first smooth noise value.
     * @param b The second smooth noise value.
     * @param theta The angle.
     * @param reciprocal The frequency reciprocal.
     * @return The interpolated value.
     */
    private static int interpolate(int a, int b, int theta, int reciprocal) {
        int cosine = 65536 - COSINE[theta * COSINE.length / (2 * reciprocal)] / 2;
        return (a * (65536 - cosine)) / 65536 + (b * cosine) / 65536;
    }
}

Related

  1. interpolate(float bottom, float top, float ratio)
  2. interpolate(float firstColor, float secondColor, float stage, float maxStages)
  3. interpolate(float s, float e, float t)
  4. interpolate(float t, float a, float b)
  5. interpolate(float var1, float var2, float var3)
  6. interpolate(int i, int n, float u1, float u2, float du)
  7. interpolate(int start, int end, int n, int i)
  8. interpolate(int v1, int v2, float f)
  9. interpolate(int v1, int v2, float f)