Code Monkey home page Code Monkey logo

math's People

Contributors

astei avatar ddos avatar dependabot[bot] avatar juliewoolie avatar kashike avatar kitskub avatar lukespragg avatar renovate[bot] avatar sleaker avatar wolf480pl avatar zml2008 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): Update dependency org.junit:junit-bom to v5.10.2

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/check-spotless.yaml
.github/workflows/ci.yaml
gradle
gradle.properties
settings.gradle
  • org.gradle.toolchains.foojay-resolver-convention 0.8.0
build.gradle
gradle/libs.versions.toml
  • com.google.errorprone:error_prone_core 2.23.0
  • com.google.errorprone:error_prone_annotations 2.23.0
  • org.junit:junit-bom 5.10.1
  • net.kyori.blossom 2.1.0
  • net.ltgt.errorprone 3.1.0
  • org.jetbrains.gradle.plugin.idea-ext 1.1.7
  • net.kyori.indra 3.1.3
  • net.kyori.indra.crossdoc 3.1.3
  • net.kyori.indra.licenser.spotless 3.1.3
  • net.kyori.indra.publishing.sonatype 3.1.3
  • org.spongepowered.gradle.sponge.dev 2.2.0
  • com.diffplug.spotless 6.25.0
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.6

  • Check this box to trigger a request for Renovate to run again on this repository

Javadoc warnings on compile

[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2d.java:254: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2d.java:264: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2f.java:254: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2f.java:264: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2i.java:221: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2i.java:231: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2l.java:221: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector2l.java:231: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3d.java:288: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3d.java:298: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3f.java:288: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3f.java:298: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3i.java:250: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3i.java:260: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3l.java:250: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector3l.java:260: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4d.java:291: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4d.java:314: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4f.java:291: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4f.java:314: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4i.java:247: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4i.java:270: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4l.java:247: warning - Tag @link: reference not found: int
[WARNING] target/generated-sources/template/com/flowpowered/math/vector/Vector4l.java:270: warning - Tag @link: reference not found: int

Add support for Configurate

Currently in order to use the math types in Configurate you need to implement your own TypeSerializers. It would be nice if these were provided out of the box for easier use and reduce the bloat needed for each plugin.

Common interfaces for types

It would be a nice addition to have a common interface for all "types".

Vector
Matrix
Complex
Imaginary
Quaternion

useless volatile

in the Vector Matrix classes etc we can observe 2 fields

private transient volatile boolean hashed = false;
private transient volatile int hashCode = 0;

The reasons why we can safely remove volatile are:

  • Our primitives do aligned reading on all platforms (int 32 bit and boolean)

  • And the second, since we have all the fields of this class (x y z) immutable, therefore the race will not destroy anything for us

The solution, and yet you can step on a rake if you read from the heap several times, so we have to read 1 time, the final result of the hashCode should look like this:

@Override
public int hashCode() {
   int h = hashCode; // read only ONCE
   if (h == 0 && !hashed) {
       h = calc Hash code
       if (h == 0) {
           hashed = true;
       } else {
           hashCode = h;
       }
   }
   return h;
}

This will remove volatile on hashed and hashCode fields

Create Matrix/Vector from array

When reading binary files, it would be useful to be able to create Matrices and Vectors from primitive arrays. Currently, this is only possible for the MatrixN or VectorN classes, if I want an object of specific size, I need to copy it manually or create it from an N object which is additional overhead.

Javadoc errors on compile

[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:62: error: malformed HTML
[ERROR] * @return -180 < angle <= 180
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:62: error: malformed HTML
[ERROR] * @return -180 < angle <= 180
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:79: error: malformed HTML
[ERROR] * @return -PI < radian <= PI
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:79: error: malformed HTML
[ERROR] * @return -PI < radian <= PI
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:96: error: malformed HTML
[ERROR] * @return -90 < angle < 90
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:96: error: malformed HTML
[ERROR] * @return -90 < angle < 90
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:113: error: malformed HTML
[ERROR] * @return 0 < byte < 256
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:113: error: malformed HTML
[ERROR] * @return 0 < byte < 256
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\GenericMath.java:747: warning: no @param for num
[ERROR] public static boolean isPowerOfTwo(int num) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:48: warning: no @param for value
[ERROR] public static int hash(double value) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:62: warning: no @param for value
[ERROR] public static int hash(float value) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:74: warning: no @param for value
[ERROR] public static int hash(int value) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:83: warning: no @param for value
[ERROR] public static int hash(long value) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:92: warning: no @param for object
[ERROR] public static int hash(Object object) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:99: warning: no @param for v
[ERROR] public static int fastCeil(float v) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\HashFunctions.java:99: warning: no @return
[ERROR] public static int fastCeil(float v) {
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\TrigMath.java:73: error: self-closing element not allowed
[ERROR] * Sine calculation using a table. <p/> <b>No interpolation is performed:</b> Accuracy is up to the 6th decimal place
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\TrigMath.java:83: error: self-closing element not allowed
[ERROR] * Cosine calculation using a table. <p/> <b>No interpolation is performed:</b> Accuracy is up to the 6th decimal place
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\TrigMath.java:93: error: self-closing element not allowed
[ERROR] * Tangent calculations using a table.<br> <i>sin(angle) / cos(angle)</i><br><br> <p/> <b>No interpolation is performed:</b> Accuracy is up to the 6th decimal place
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\TrigMath.java:104: error: self-closing element not allowed
[ERROR] * Cosecant calculations using a table.<br> <i>1 / sin(angle)</i><br><br> <p/> <b>No interpolation is performed:</b> Accuracy is up to the 6th decimal place
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\TrigMath.java:114: error: self-closing element not allowed
[ERROR] * Secant calculations using a table:<br> <i>1 / cos(angle)</i><br><br> <p/> <b>No interpolation is performed:</b> Accuracy is up to the 6th decimal place
[ERROR] ^
[ERROR] src\main\java\com\flowpowered\math\TrigMath.java:124: error: self-closing element not allowed
[ERROR] * Cotangent calculations using a table.<br> <i>cos(angle) / sin(angle)</i><br><br> <p/> <b>No interpolation is performed:</b> Accuracy is up to the 6th decimal place
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\imaginary\Quaterniond.java:389: warning: nested tag not allowed: <sup>
[ERROR] * <code>|a|<sup>2<sup/></code> is squared length of <code>a</code>.
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\imaginary\Quaterniond.java:389: error: self-closing element not allowed
[ERROR] * <code>|a|<sup>2<sup/></code> is squared length of <code>a</code>.
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\imaginary\Quaterniond.java:389: error: end tag missing: </sup>
[ERROR] * <code>|a|<sup>2<sup/></code> is squared length of <code>a</code>.
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\imaginary\Quaternionf.java:389: warning: nested tag not allowed: <sup>
[ERROR] * <code>|a|<sup>2<sup/></code> is squared length of <code>a</code>.
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\imaginary\Quaternionf.java:389: error: self-closing element not allowed
[ERROR] * <code>|a|<sup>2<sup/></code> is squared length of <code>a</code>.
[ERROR] ^
[ERROR] target\generated-sources\template\com\flowpowered\math\imaginary\Quaternionf.java:389: error: end tag missing: </sup>
[ERROR] * <code>|a|<sup>2<sup/></code> is squared length of <code>a</code>.
[ERROR] ^

Loss of precision of integers

@Override
public Vector3d toDouble() {
return new Vector3d(this.x, this.y, this.z);
}

This method calls a constructor that takes a float, which causes some numbers such as 29,999,999 to become 30,000,000.
Test code that reproduces the bug:

Vector3i blockPosition = Vector3i.from(29999999, 0, 0);

System.out.println(blockPosition);
System.out.println(blockPosition.toDouble().toInt());

Output:

(29999999, 0, 0)
(30000000, 0, 0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.