MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / __sub__

Method __sub__

src/main/java/field/graphics/FLine.java:1853–1914  ·  view source on GitHub ↗
(Object b)

Source from the content-addressed store, hash-verified

1851 } else if (b instanceof Vec3) {
1852 Vec3 finalB = (Vec3) b;
1853 return byTransforming(x -> new Vec3(x).sub(finalB));
1854 } else if (b instanceof Quat) {
1855 Quat finalB = (Quat) b;
1856 return byTransforming(x -> finalB.invert(new Quat()).transform(x, new Vec3()));
1857 } else if (b instanceof FLine) {
1858 Shape s1 = FLinesAndJavaShapes.flineToJavaShape(this);
1859 Shape s2 = FLinesAndJavaShapes.flineToJavaShape((FLine) b);
1860
1861 Area a1 = new Area(s1);
1862 Area a2 = new Area(s2);
1863 a1.subtract(a2);
1864 FLine ret = FLinesAndJavaShapes.javaShapeToFLine(a1);
1865 ret.attributes = this.attributes.duplicate(ret);
1866 return ret;
1867 } else if (b instanceof ScriptObjectMirror && ((ScriptObjectMirror) b).isArray()) {
1868 List b2 = ((ScriptObjectMirror) b).to(List.class);
1869
1870 if (b2 instanceof List && (((List) b2).size() > 0)) {
1871
1872 Object oo = ((List) b2).get(0);
1873 if (oo instanceof Vec3) {
1874 return new FLine().append((List<FLine>) ((List) b2).stream().map(x -> this.__sub__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1875 } else if (oo instanceof Vec2) {
1876 return new FLine().append((List<FLine>) ((List) b2).stream().map(x -> this.__sub__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1877 } else if (oo instanceof OverloadedMath) {
1878 List m = (List) ((List) b2).stream().map(x -> this.__add__(x)).collect(Collectors.toList());
1879 if (m.size() > 0) {
1880 if (m.get(0) instanceof FLine) {
1881 return new FLine().append((List<FLine>) m);
1882 }
1883 }
1884 return m;
1885 }
1886 }
1887 } else if (b instanceof List && (((List) b).size() > 0)) {
1888
1889 Object oo = ((List) b).get(0);
1890 if (oo instanceof Vec3) {
1891 return new FLine().append((List<FLine>) ((List) b).stream().map(x -> this.__sub__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1892 } else if (oo instanceof Vec2) {
1893 return new FLine().append((List<FLine>) ((List) b).stream().map(x -> this.__sub__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1894 } else if (oo instanceof OverloadedMath) {
1895 List m = (List) ((List) b).stream().map(x -> this.__sub__(x)).collect(Collectors.toList());
1896 if (m.size() > 0) {
1897 if (m.get(0) instanceof FLine) {
1898 return new FLine().append((List<FLine>) m);
1899 }
1900 }
1901 return m;
1902 }
1903
1904
1905 } else if (b instanceof OverloadedMath) return ((OverloadedMath) b).__rsub__(this);
1906 throw new ClassCastException(" can't subtract '" + b + "' from this FLine");
1907 }
1908
1909 @HiddenInAutocomplete
1910 private FLine copyAttributesFrom(FLine fLine) {

Callers

nothing calls this directly

Calls 15

byTransformingMethod · 0.95
invertMethod · 0.95
flineToJavaShapeMethod · 0.95
javaShapeToFLineMethod · 0.95
__add__Method · 0.95
subtractMethod · 0.80
toMethod · 0.80
copyAttributesFromMethod · 0.80
collectMethod · 0.80
transformMethod · 0.65
duplicateMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected