<commit_before>package com.gps.capstone.traceroute.GLFiles.GLPrimitives;

import android.opengl.GLES20;
import android.opengl.Matrix;
import android.util.Log;

import com.gps.capstone.traceroute.GLFiles.util.ProgramManager;
import com.gps.capstone.traceroute.GLFiles.util.VectorLibrary;

import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

/**
 * Defines a smart rectangular prism, that doesn't depend on tons
 * of cross products to compute its position. This prism's default position
 * is centered at the origin along the x-axis. It uses a quaternion to get its position.
 */
public class SmartRectangularPrism extends DrawableObject {
    // The thickness of the rectangular prism. I made this an internal object
    //
    private static final float SIZE = 0.3f;

    // colors for the face.
    private float[] colors = {
            1.0f, 0.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 1.0f, 1.0f,
            1.0f, 1.0f, 1.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 1.0f, 1.0f, 1.0f
    };

    private final short[] drawOrder = {0,1,2, 2,3,0, 7,0,3, 3,4,7, 4,3,2, 2,5,4, 5,2,1, 1,6,5, 6,1,0, 0,7,6, 4,5,6, 6,7,4};

    public SmartRectangularPrism(ProgramManager graphicsEnv) {
        super(graphicsEnv);
    }

    public void setDimensions(float[] firstFace, float[] secondFace) {
        // This direction vector can be used to compute a quaternion with a 0 degree rotation.
        // This can be used to move all of the verticies into the right orientation, and I can use the coordinates
        // of the first face to move it into the right position. This method makes it much easier to compute surface normals,
        // as you can just take the standard unit vectors and multiply them by the quaternion to get surface normals.
        float[] directionVector = {secondFace[0] - firstFace[0], secondFace[1] - firstFace[1],
                secondFace[2] - firstFace[2]};
        // get the length of the prism
        float length = VectorLibrary.vectorLength(directionVector);

        // These are the result dimensions.
        // FIRST FACE
        // Top left, Bottom left, Bottom right, Top right
        float[] result = {0, SIZE, -SIZE, 0, -SIZE, -SIZE, 0, -SIZE, SIZE, 0, SIZE, SIZE,
                // SECOND FACE
                length, SIZE, SIZE, length, -SIZE, SIZE, length, -SIZE, -SIZE, length, SIZE, -SIZE};
        // xz angle (y-axis rotation)
        float angleOne = (float)Math.atan(directionVector[2] / directionVector[0]);
        // convert this shit to degrees.
        angleOne = (float)((angleOne / (2 * Math.PI)) * 360);
        // xy angle (z axis rotation)
        float angleTwo = (float)Math.atan(directionVector[1] / directionVector[0]);
        // convert this to degrees.
        angleTwo = (float)((angleTwo / (2 * Math.PI)) * 360);
        Log.d("ANGLE", "Y angle: " + angleOne);
        Log.d("ANGLE", "Z angle: " + angleTwo);

        // y axis rotation
        Matrix.rotateM(result, 0, angleOne, 0, 100, 0);

        // z axis rotation
        Matrix.rotateM(result, 0, angleTwo, 0, 0, 100);

        // transposition into the correct location.
        for (int i = 0 ; i < result.length; i++) {
            result[i] += firstFace[i % 3];
        }

        setVerticies(result);
    }<commit_msg>Added rotation code, but it's not working yet:<commit_after>package com.gps.capstone.traceroute.GLFiles.GLPrimitives;

import android.opengl.GLES20;
import android.opengl.Matrix;
import android.util.Log;

import com.gps.capstone.traceroute.GLFiles.util.ProgramManager;
import com.gps.capstone.traceroute.GLFiles.util.VectorLibrary;

import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

/**
 * Defines a smart rectangular prism, that doesn't depend on tons
 * of cross products to compute its position. This prism's default position
 * is centered at the origin along the x-axis. It uses a quaternion to get its position.
 */
public class SmartRectangularPrism extends DrawableObject {
    // The thickness of the rectangular prism. I made this an internal object
    // field because it's not going to change very often.
    private static final float SIZE = 0.3f;

    // colors for the face.
    private float[] colors = {
            1.0f, 0.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 1.0f, 1.0f,
            1.0f, 1.0f, 1.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 1.0f, 1.0f, 1.0f
    };

    private final short[] drawOrder = {0,1,2, 2,3,0, 7,0,3, 3,4,7, 4,3,2, 2,5,4, 5,2,1, 1,6,5, 6,1,0, 0,7,6, 4,5,6, 6,7,4};

    public SmartRectangularPrism(ProgramManager graphicsEnv) {
        super(graphicsEnv);
    }

    public void setDimensions(float[] firstFace, float[] secondFace) {
        // This direction vector can be used to compute a quaternion with a 0 degree rotation.
        // This can be used to move all of the verticies into the right orientation, and I can use the coordinates
        // of the first face to move it into the right position. This method makes it much easier to compute surface normals,
        // as you can just take the standard unit vectors and multiply them by the quaternion to get surface normals.
        float[] directionVector = {secondFace[0] - firstFace[0], secondFace[1] - firstFace[1],
                secondFace[2] - firstFace[2]};
        // get the length of the prism
        float length = VectorLibrary.vectorLength(directionVector);

        // These are the result dimensions.
        // FIRST FACE
        // Top left, Bottom left, Bottom right, Top right
        float[] result = {0, SIZE, -SIZE, 0, -SIZE, -SIZE, 0, -SIZE, SIZE, 0, SIZE, SIZE,
                // SECOND FACE
                length, SIZE, SIZE, length, -SIZE, SIZE, length, -SIZE, -SIZE, length, SIZE, -SIZE};
        // xz angle (y-axis rotation)
        float angleOne = (float)Math.atan(directionVector[2] / directionVector[0]);
        // convert this shit to degrees.
        angleOne = (float)((angleOne / (2 * Math.PI)) * 360);
        // xy angle (z axis rotation)
        float angleTwo = (float)Math.atan(directionVector[1] / directionVector[0]);
        // convert this to degrees.
        angleTwo = (float)((angleTwo / (2 * Math.PI)) * 360);
        Log.d("ANGLE", "Y angle: " + angleOne);
        Log.d("ANGLE", "Z angle: " + angleTwo);

        float[] rotationMat = new float[16];

        // set up a rotation matrix.
        Matrix.setIdentityM(rotationMat, 0);

        // y axis rotation
        Matrix.rotateM(rotationMat, 0, angleOne, 0, 100, 0);

        // z axis rotation
        Matrix.rotateM(rotationMat, 0, angleTwo, 0, 0, 100);

        // loop through and apply the rotation to each vertex.
        /*for (int i = 0; i < result.length; i += 3) {
            // grab the current vertex in 4-d space.
            float[] curVec = {result[i], result[i+1], result[i+2], 0};
            float[] resultVec = new float[4];

            Matrix.multiplyMV(resultVec, 0, rotationMat, 0, curVec, 0);

            // update the object array with the rotated vertex.
            for (int j = 0; i < DrawableObject.DIMENSIONS; i++) {
                result[i + j] = resultVec[j];
            }
        }*/

        // transposition into the correct location.
        for (int i = 0 ; i < result.length; i++) {
            result[i] += firstFace[i % 3];
        }

        setVerticies(result);
    }
{'fraction_non_alphanumeric': 0.12321523003701745, 'fraction_numerical': 0.03913273400317292, 'mean_word_length': 2.2877009995654065, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6967179', 'n_tokens_mistral': 2611, 'n_tokens_neox': 2398, 'n_words': 793}