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

Method __div__

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

Source from the content-addressed store, hash-verified

2083 Vec3 finalB = ((Vec2) b).toVec3();
2084 return byTransforming(x -> new Vec3(x).div(finalB));
2085 } else if (b instanceof Vec3) {
2086 Vec3 finalB = (Vec3) b;
2087 return byTransforming(x -> new Vec3(x).div(finalB));
2088 } else if (b instanceof Quat) {
2089 Quat finalB = new Quat();
2090 ((Quat) b).invert(finalB);
2091 return byTransforming(x -> finalB.transform(x, new Vec3()));
2092 } else if (b instanceof ScriptObjectMirror && ((ScriptObjectMirror) b).isArray()) {
2093 List b2 = ((ScriptObjectMirror) b).to(List.class);
2094
2095 if (b2 instanceof List && (((List) b2).size() > 0)) {
2096
2097 Object oo = ((List) b2).get(0);
2098 if (oo instanceof Vec3) {
2099 return new FLine().append((List<FLine>) ((List) b2).stream().map(x -> this.__div__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
2100 } else if (oo instanceof Vec2) {
2101 return new FLine().append((List<FLine>) ((List) b2).stream().map(x -> this.__div__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
2102 } else if (oo instanceof OverloadedMath) {
2103 List m = (List) ((List) b2).stream().map(x -> this.__div__(x)).collect(Collectors.toList());
2104 if (m.size() > 0) {
2105 if (m.get(0) instanceof FLine) {
2106 return new FLine().append((List<FLine>) m).copyAttributesFrom(this);
2107 }
2108 }
2109 return m;
2110 }
2111 }
2112 } else if (b instanceof FLine) {
2113 Shape s1 = FLinesAndJavaShapes.flineToJavaShape(this);
2114 Shape s2 = FLinesAndJavaShapes.flineToJavaShape((FLine) b);
2115
2116 Area a1 = new Area(s1);
2117 Area a2 = new Area(s2);
2118 a1.intersect(a2);
2119 FLine ret = FLinesAndJavaShapes.javaShapeToFLine(a1);
2120 ret.attributes = this.attributes.duplicate(ret);
2121 return ret;
2122 } else if (b instanceof OverloadedMath) return ((OverloadedMath) b).__rdiv__(this);
2123 throw new ClassCastException(" can't multiply '" + b + "' to this FLine");
2124 }
2125
2126 Vec3 heading = new Vec3(1, 0, 0);
2127
2128 public Vec3 forward() {
2129 return forward(1);
2130 }
2131
2132 public Vec3 forward(double stepSize) {
2133 return new Vec3(heading).mul(stepSize).add(node().to);
2134 }

Callers

nothing calls this directly

Calls 15

byTransformingMethod · 0.95
transformMethod · 0.95
flineToJavaShapeMethod · 0.95
javaShapeToFLineMethod · 0.95
toMethod · 0.80
copyAttributesFromMethod · 0.80
collectMethod · 0.80
getMethod · 0.65
duplicateMethod · 0.65
__rdiv__Method · 0.65
scaleMethod · 0.45
toVec3Method · 0.45

Tested by

no test coverage detected