diff --git a/core/src/love/distributedrebirth/demo4d/fraction4d/GroßGetậl.java b/core/src/love/distributedrebirth/demo4d/fraction4d/GroßGetậl.java new file mode 100644 index 00000000..456b9b3c --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/fraction4d/GroßGetậl.java @@ -0,0 +1,50 @@ +package love.distributedrebirth.demo4d.fraction4d; + +import java.util.ArrayList; +import java.util.List; + +import love.distributedrebirth.demo4d.base2t.V009Tyte; +import love.distributedrebirth.demo4d.base2t.V009TyteBaseAppender; +import love.distributedrebirth.demo4d.base2t.V009TyteIterator; +import love.distributedrebirth.demo4d.base2t.V144Tocta; + +public class GroßGetậl { + + public static int NUMERATOR_SIZE = 7; + public static int DENOMINATOR_SIZE = 9; + private final V009Tyte[] numerator = new V009Tyte[NUMERATOR_SIZE]; + private final V009Tyte[] denominator = new V009Tyte[DENOMINATOR_SIZE]; + + public GroßGetậl() { + for (int i=0;i tytes = new ArrayList<>(); + tocta.fillTyteValues(new V009TyteBaseAppender(tytes)); + for (int i=0;i tytes = new ArrayList<>(); + for (int i=0;i> HebrewGetậlLetter.SHIFT_5); + } + + public V009Tyte toTyte() { + int combinedValue = letter.ordinal() + (vowel.ordinal() << HebrewGetậlLetter.SHIFT_5); + T08PartOctal value0 = T08PartOctal.indexOf(T08PartOctal.PART_1, combinedValue); + T08PartOctal value1 = T08PartOctal.indexOf(T08PartOctal.PART_2, combinedValue); + T08PartOctal value2 = T08PartOctal.indexOf(T08PartOctal.PART_3, combinedValue); + return new V009Tyte(value0, value1, value2); + } + + public double toDecimalValue(boolean firstChar) { + double fraction = letter.getDecimal(); + if (firstChar) { + return fraction; // use full value + } + if (!HebrewGetậlVowel.NONE.equals(vowel)) { + fraction = fraction * Math.pow(FRACTION_POWER, vowel.getFractionOffset()); + } + double result = NUMERATOR_ONE/fraction; + return result; + } + + public HebrewGetậlLetter getLetter() { + return letter; + } + + public void setLetter(HebrewGetậlLetter letter) { + this.letter = letter; + } + + public HebrewGetậlVowel getVowel() { + return vowel; + } + + public void setVowel(HebrewGetậlVowel vowel) { + this.vowel = vowel; + } +} diff --git a/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGetậlLetter.java b/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGetậlLetter.java new file mode 100644 index 00000000..802bc2bb --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGetậlLetter.java @@ -0,0 +1,98 @@ +package love.distributedrebirth.demo4d.fraction4d; + +public enum HebrewGetậlLetter { + // Unicode is horror in any language else than ascii; + // VS Alphabet order + // VS Unicode order + // VS Gematria order <== leading but with other decimals + + NONE (0, (char) 0x05EF), + + LETTER_1 (1, (char) 0x05D0), + LETTER_2 (2, (char) 0x05D1), + LETTER_3 (3, (char) 0x05D2), + LETTER_4 (4, (char) 0x05D3), + LETTER_5 (5, (char) 0x05D4), + LETTER_6 (6, (char) 0x05D5), + LETTER_7 (7, (char) 0x05D6), + LETTER_8 (8, (char) 0x05D7), + LETTER_9 (9, (char) 0x05D8), + + LETTER_11 (11, (char) 0x05D9), + LETTER_12 (12, (char) 0x05DB), + LETTER_13 (13, (char) 0x05DC), + LETTER_14 (14, (char) 0x05DE), + LETTER_15 (15, (char) 0x05E0), + LETTER_16 (16, (char) 0x05E1), + LETTER_17 (17, (char) 0x05E2), + LETTER_18 (18, (char) 0x05E4), + LETTER_19 (19, (char) 0x05E6), + + LETTER_21 (21, (char) 0x05E7), + LETTER_22 (22, (char) 0x05E8), + LETTER_23 (23, (char) 0x05E9), + LETTER_24 (24, (char) 0x05EA), + LETTER_25 (25, (char) 0x05DA), + LETTER_26 (26, (char) 0x05DD), + LETTER_27 (27, (char) 0x05DF), + LETTER_28 (28, (char) 0x05E3), + LETTER_29 (29, (char) 0x05E5), + +/* // OLD + LETTER_11 (10, (char) 0x05D9), + LETTER_12 (20, (char) 0x05DB), + LETTER_13 (30, (char) 0x05DC), + LETTER_14 (40, (char) 0x05DE), + LETTER_15 (50, (char) 0x05E0), + LETTER_16 (60, (char) 0x05E1), + LETTER_17 (70, (char) 0x05E2), + LETTER_18 (80, (char) 0x05E4), + LETTER_19 (90, (char) 0x05E6), + + LETTER_21 (100, (char) 0x05E7), + LETTER_22 (200, (char) 0x05E8), + LETTER_23 (300, (char) 0x05E9), + LETTER_24 (400, (char) 0x05EA), + LETTER_25 (500, (char) 0x05DA), + LETTER_26 (600, (char) 0x05DD), + LETTER_27 (700, (char) 0x05DF), + LETTER_28 (800, (char) 0x05E3), + LETTER_29 (900, (char) 0x05E5), + */ + LETTER_31 (31, (char) 0x05BE), + LETTER_32 (32, (char) 0x05C0), + LETTER_33 (33, (char) 0x05C3), + LETTER_34 (34, (char) 0x05C6), + ; + + public static final byte BITMASK = 0b00011111; + public static final byte SHIFT_5 = 5; + private final int decimal; + private final char character; + + private HebrewGetậlLetter(int decimal, char character) { + this.decimal = decimal; + this.character = character; + } + + public int getDecimal() { + return decimal; + } + + public char getCharacter() { + return character; + } + + public static HebrewGetậlLetter indexOf(int index) { + return values()[index & BITMASK]; + } + + public static HebrewGetậlLetter valueOf(char codePoint) { + for (HebrewGetậlLetter vowel:values()) { + if (vowel.getCharacter() == codePoint) { + return vowel; + } + } + return HebrewGetậlLetter.NONE; + } +} diff --git a/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGetậlVowel.java b/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGetậlVowel.java new file mode 100644 index 00000000..1f9d12f4 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGetậlVowel.java @@ -0,0 +1,51 @@ +package love.distributedrebirth.demo4d.fraction4d; + +public enum HebrewGetậlVowel { + NONE (0, (char) 0x0000), + VOWEL_1 (1, (char) 0x05B4), + VOWEL_2 (2, (char) 0x05B5), + VOWEL_3 (3, (char) 0x05B6), + VOWEL_4 (4, (char) 0x05B2), + VOWEL_5 (5, (char) 0x05C7), + VOWEL_6 (6, (char) 0x05B7), // 06 = PATAH + VOWEL_7 (7, (char) 0x05A1), + VOWEL_8 (8, (char) 0x05A2), + VOWEL_9 (9, (char) 0x05A3), + VOWEL_10 (10, (char) 0x05B9), // 10 = POINT HOLAM + VOWEL_16 (16, (char) 0x05B8), // 16 = QAMATS + VOWEL_22 (22, (char) 0x0598), + VOWEL_30 (30, (char) 0x05BB), // 30 = QUBUTS + VOWEL_36 (36, (char) 0x05B3), // 36 = HATAF QAMATS + VOWEL_42 (42, (char) 0x05B1), // 50 = HATEF SEGOL + ; + + public static final byte BITMASK = 0b00001111; + private final int fractionOffset; + private final char character; + + private HebrewGetậlVowel(int fractionOffset, char character) { + this.fractionOffset = fractionOffset; + this.character = character; + } + + public int getFractionOffset() { + return fractionOffset; + } + + public char getCharacter() { + return character; + } + + public static HebrewGetậlVowel indexOf(int index) { + return values()[index & BITMASK]; + } + + public static HebrewGetậlVowel valueOf(char codePoint) { + for (HebrewGetậlVowel vowel:values()) { + if (vowel.getCharacter() == codePoint) { + return vowel; + } + } + return HebrewGetậlVowel.NONE; + } +} diff --git a/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGê̄ld.java b/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGê̄ld.java new file mode 100644 index 00000000..7d5c2638 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/fraction4d/HebrewGê̄ld.java @@ -0,0 +1,187 @@ +package love.distributedrebirth.demo4d.fraction4d; + +import java.util.ArrayList; +import java.util.List; + +import love.distributedrebirth.demo4d.base2t.T04PartQuad; +import love.distributedrebirth.demo4d.base2t.V018Tord; +import love.distributedrebirth.demo4d.base2t.V036Teger; + +public class HebrewGê̄ld { + + private final HebrewGetậl nummerAlphabet; + private final HebrewGetậl nummerDeelA; + private final HebrewGetậl nummerDeelB; + private final HebrewGetậl nummerDeelC; + private final double totalDecimalValue; + private static final Character LEFT_TO_RIGHT_MARK = 0x200E; + private static final Character RIGHT_TO_LEFT_MARK = 0x200F; + + public HebrewGê̄ld(V036Teger teger) { + this( + new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_1)), + new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_2)), + new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_3)), + new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_4)) + ); + } + + public HebrewGê̄ld(HebrewGetậl nummerAlphabet, HebrewGetậl nummerDeelA, HebrewGetậl nummerDeelB, HebrewGetậl nummerDeelC) { + this.nummerAlphabet = nummerAlphabet; + this.nummerDeelA = nummerDeelA; + this.nummerDeelB = nummerDeelB; + this.nummerDeelC = nummerDeelC; + this.totalDecimalValue = calculateDecimalValue(); + } + + public HebrewGê̄ld(String money) { + if (money == null) { + throw new NullPointerException("Can't parse null money"); + } + if (money.isEmpty()) { + throw new IllegalArgumentException("Can't parse zero money length"); + } + if (money.length() > 8) { // RL + 4 chars + 3 vowels + throw new IllegalArgumentException("Money length should not exceed 8 codepoints"); + } + List result = new ArrayList<>(); + + HebrewGetậl geldDigit = null; + for (int i=0;i 1) { + deelA = result.get(1); + } else { + deelA = new HebrewGetậl(); + } + if (result.size() > 2) { + deelB = result.get(2); + } else { + deelB = new HebrewGetậl(); + } + if (result.size() > 3) { + deelC = result.get(3); + } else { + deelC = new HebrewGetậl(); + } + this.nummerAlphabet = full; + this.nummerDeelA = deelA; + this.nummerDeelB = deelB; + this.nummerDeelC = deelC; + this.totalDecimalValue = calculateDecimalValue(); + } + + private double calculateDecimalValue() { + boolean hasFourDigits = + !HebrewGetậlLetter.NONE.equals(nummerDeelA.getLetter()) && + !HebrewGetậlLetter.NONE.equals(nummerDeelB.getLetter()) && + !HebrewGetậlLetter.NONE.equals(nummerDeelC.getLetter()); + double totalDecimalValue = nummerAlphabet.toDecimalValue(hasFourDigits); + if (!HebrewGetậlLetter.NONE.equals(nummerDeelA.getLetter())) { + totalDecimalValue += nummerDeelA.toDecimalValue(false); + } + if (!HebrewGetậlLetter.NONE.equals(nummerDeelB.getLetter())) { + totalDecimalValue += nummerDeelB.toDecimalValue(false); + } + if (!HebrewGetậlLetter.NONE.equals(nummerDeelC.getLetter())) { + totalDecimalValue += nummerDeelC.toDecimalValue(false); + } + return totalDecimalValue; + } + + public HebrewGetậl getNummerAlphabet() { + return nummerAlphabet; + } + + public HebrewGetậl getNummerDeelA() { + return nummerDeelA; + } + + public HebrewGetậl getNummerDeelB() { + return nummerDeelB; + } + + public HebrewGetậl getNummerDeelC() { + return nummerDeelC; + } + + public double getTotalDecimalValue() { + return totalDecimalValue; + } + + public V036Teger toTeger() { + return new V036Teger( + new V018Tord(nummerAlphabet.toTyte(), nummerDeelA.toTyte()), + new V018Tord(nummerDeelB.toTyte(), nummerDeelC.toTyte()) + ); + } + + public String toHebrewString() { + return toHebrewString(false); + } + + public String toHebrewString(boolean reverse) { + StringBuilder buf = new StringBuilder(); + buf.append(RIGHT_TO_LEFT_MARK); + buf.append(nummerAlphabet.getLetter().getCharacter()); + if (!HebrewGetậlVowel.NONE.equals(nummerAlphabet.getVowel())) { + buf.append(nummerAlphabet.getVowel().getCharacter()); + } + if (!HebrewGetậlLetter.NONE.equals(nummerDeelA.getLetter())) { + buf.append(nummerDeelA.getLetter().getCharacter()); + if (!HebrewGetậlVowel.NONE.equals(nummerDeelA.getVowel())) { + buf.append(nummerDeelA.getVowel().getCharacter()); + } + } + if (!HebrewGetậlLetter.NONE.equals(nummerDeelB.getLetter())) { + buf.append(nummerDeelB.getLetter().getCharacter()); + if (!HebrewGetậlVowel.NONE.equals(nummerDeelB.getVowel())) { + buf.append(nummerDeelB.getVowel().getCharacter()); + } + } + if (!HebrewGetậlLetter.NONE.equals(nummerDeelC.getLetter())) { + buf.append(nummerDeelC.getLetter().getCharacter()); + if (!HebrewGetậlVowel.NONE.equals(nummerDeelC.getVowel())) { + buf.append(nummerDeelC.getVowel().getCharacter()); + } + } + if (reverse) { + buf.reverse(); // ImGui skips RL marker so renders wrong.... + } + return buf.toString(); + } +}