Vectors created using VectorZ
Code: "BasicVectorUsage.java". Programming language: Java DMelt Version 2.3. Last modified: 11/26/1972. License: Pro
https://datamelt.org/code/cache/BasicVectorUsage_2991.java
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


import mikera.matrixx.Matrix33;
import mikera.matrixx.Matrixx;
import mikera.vectorz.Vector3;

public class BasicVectorUsage {

        public static void main(String[] args) {
                Vector3 v=Vector3.of(1.0,2.0,3.0);
                System.out.println(v);

                v.normalise();
                System.out.println(v);

                Vector3 d=Vector3.of(10.0,0.0,0.0);
                d.addMultiple(v, 5.0);
                System.out.println(d);

                Matrix33 m=Matrixx.createXAxisRotationMatrix(Math.PI);
                Vector3 rotated=m.transform(d);      // rotate 180 degrees around x axis     
                System.out.println(rotated);

        }

}


You see the box below because you did not login.