Added new mesh class Rewrite mesh algorithms to be less error prone Make code more concise Tried to add some documentation Added half edge set
43 lines
1.5 KiB
Java
43 lines
1.5 KiB
Java
package com.aaaaahhhhhhh.bananapuncher714.mesh;
|
|
|
|
public class Test {
|
|
public static void main( String[] args ) {
|
|
final Vector2d a = new Vector2d( -1, -1 );
|
|
final Vector2d b = new Vector2d( 10, 10 );
|
|
final Vector2d c = new Vector2d( 0, -1 );
|
|
final Vector2d d = new Vector2d( 10, 11 );
|
|
|
|
test( a, b, c, d );
|
|
}
|
|
|
|
public static void test( final Vector2d a, final Vector2d b, final Vector2d c, final Vector2d d ) {
|
|
final Vector2d ab = b.subtracted( a );
|
|
final Vector2d cd = d.subtracted( c );
|
|
|
|
final Vector2d ac = c.subtracted( a );
|
|
|
|
final double acab = ac.cross( ab );
|
|
final double abcd = ab.cross( cd );
|
|
|
|
System.out.println( "Parallel value: " + abcd );
|
|
if ( abcd != 0 ) {
|
|
final double s = ac.cross( cd );
|
|
final double t = s / abcd;
|
|
final double u = acab / abcd;
|
|
|
|
System.out.println( "S: " + s );
|
|
System.out.println( "T: " + t );
|
|
System.out.println( "U: " + u );
|
|
|
|
System.out.println( "AB Length: " + ( t * ab.length() ) );
|
|
System.out.println( "CD Length: " + ( u * cd.length() ) );
|
|
|
|
// Gives the intersection correctly
|
|
System.out.println( "AB int: " + ab.multiplied( t ).add( a ) );
|
|
System.out.println( "CD int: " + cd.multiplied( u ).add( c ) );
|
|
} else {
|
|
|
|
}
|
|
}
|
|
}
|