!hmxATAkDoZHphjybaM:matrix.org

Blender

1038 Members
Unofficial help & discussion | Blender Community: #Blender.org:matrix.org87 Servers

Load older messages


SenderMessageTime
15 May 2022
@klugmathias:matrix.org0.Eth3rnal_image.png
Download image.png
21:25:44
@klugmathias:matrix.org0.Eth3rnal_ * Eg. haskell, too:21:25:48
@klugmathias:matrix.org0.Eth3rnal_I wrote this by writing a bit, testing, adding a bit, testing...21:26:28
@klugmathias:matrix.org0.Eth3rnal_Which is slightly diff than I write most things21:26:37
@klugmathias:matrix.org0.Eth3rnal_This method tends to end up with sphagetti code21:26:54
@klugmathias:matrix.org0.Eth3rnal_ * This method tends to end up with spaghetti code21:26:57
@klugmathias:matrix.org0.Eth3rnal_If I actually think tho21:27:43
@klugmathias:matrix.org0.Eth3rnal_image.png
Download image.png
21:27:46
@klugmathias:matrix.org0.Eth3rnal_The readability here sucks cuz this is not how you write haskell normally, but much better than one-liners21:28:13
@klugmathias:matrix.org0.Eth3rnal_ Well, it is readable but not pretty 21:28:41
@klugmathias:matrix.org0.Eth3rnal_Anyway21:29:26
@nodespaghetti:matrix.nodespaghetti.clubnodespaghetti
In reply to @klugmathias:matrix.org
This method tends to end up with spaghetti code
Guess I can't really criticize spaghetti code lol
22:29:21
16 May 2022
@klugmathias:matrix.org0.Eth3rnal_
In reply to @nodespaghetti:matrix.nodespaghetti.club
Guess I can't really criticize spaghetti code lol
:P
01:07:35
@klugmathias:matrix.org0.Eth3rnal_For good measure, here's some spaghetti python01:07:59
@klugmathias:matrix.org0.Eth3rnal_
    def __mul__(self, other):
        if type(other) == Fraction:
            res = (self.val * other.val, self.exp * other.exp)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])
        elif type(other) == Float:
            ofrac = other.get_fraction()
            res = (self.val * ofrac.val, self.exp * ofrac.exp)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])

    def __truediv__(self, other):
        if type(other) == Fraction:
            return self.__mul__(other.invert())
        elif type(other) == Float:
            return self.__mul__(other.get_fraction().invert())

    def __add__(self, other):
        if type(other) == Fraction:
            flcm = math.lcm(self.exp, other.exp)
            sv = self.val * (flcm//self.exp)
            ov = other.val * (flcm//other.exp)
            res = (sv + ov, flcm)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])
        elif type(other) == Float:
            ofrac = other.get_fraction()
            flcm = math.lcm(self.exp, ofrac.exp)
            sv = self.val * (flcm//self.exp)
            ov = ofrac.val * (flcm//ofrac.exp)
            res = (sv + ov, flcm)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])
01:08:18
@klugmathias:matrix.org0.Eth3rnal_ *
class Fraction:
    def __init__(self, val, exp):
        self.val, self.exp = simplify(val, exp)

    def invert(self):
        val = self.val
        self.val = self.exp
        self.exp = val
        return self

    def sign_flip(self):
        self.val = -self.val
        return self

    def __mul__(self, other):
        if type(other) == Fraction:
            res = (self.val * other.val, self.exp * other.exp)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])
        elif type(other) == Float:
            ofrac = other.get_fraction()
            res = (self.val * ofrac.val, self.exp * ofrac.exp)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])

    def __truediv__(self, other):
        if type(other) == Fraction:
            return self.__mul__(other.invert())
        elif type(other) == Float:
            return self.__mul__(other.get_fraction().invert())

    def __add__(self, other):
        if type(other) == Fraction:
            flcm = math.lcm(self.exp, other.exp)
            sv = self.val * (flcm//self.exp)
            ov = other.val * (flcm//other.exp)
            res = (sv + ov, flcm)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])
        elif type(other) == Float:
            ofrac = other.get_fraction()
            flcm = math.lcm(self.exp, ofrac.exp)
            sv = self.val * (flcm//self.exp)
            ov = ofrac.val * (flcm//ofrac.exp)
            res = (sv + ov, flcm)
            v, e, i = get_float(res[0], res[1])
            if i: return Float(v, e)
            else: return Fraction(res[0], res[1])

    def __sub__(self, other):
        if type(other) == Fraction:
            return self.__mul__(other.sign_flip())
        elif type(other) == Float:
            return self.__mul__(other.get_fraction().sign_flip())

    def __eq__(self, other):
        if type(other) == Float:
            othfr = other.get_fraction()
            return self.val == othfr.val and self.exp == othfr.exp
        elif type(other) == Fraction:
            return self.val == other.val and self.exp == other.exp

    def __gt__(self, other):
        if type(other) == Fraction:
            flcm = math.lcm(self.exp, other.exp)
            sv = self.val * (flcm//self.exp)
            ov = other.val * (flcm//other.exp)
            return sv > ov
        elif type(other) == Float:
            othfr = other.get_fraction()
            flcm = math.lcm(self.exp, othfr.exp)
            sv = self.val * (flcm//self.exp)
            ov = othfr.val * (flcm//othfr.exp)
            return sv > ov

    def __ge__(self, other):
        if self == other: return True
        else: return self > other

    def __lt__(self, other):
        if type(other) == Fraction:
            flcm = math.lcm(self.exp, other.exp)
            sv = self.val * (flcm//self.exp)
            ov = other.val * (flcm//other.exp)
            return sv < ov
        elif type(other) == Float:
            othfr = other.get_fraction()
            flcm = math.lcm(self.exp, othfr.exp)
            sv = self.val * (flcm//self.exp)
            ov = othfr.val * (flcm//othfr.exp)
            return sv < ov

    def __le__(self, other):
        if self == other: return True
        else: return self < other

    def __str__(self):
        return f'{self.val}/{self.exp}'

    def __repr__(self):
        return self.__str__()

01:09:00
@klugmathias:matrix.org0.Eth3rnal_It's from my infloats lib, for infinite precision mathematics 01:09:17
@klugmathias:matrix.org0.Eth3rnal_Lol01:09:18
@klugmathias:matrix.org0.Eth3rnal_Single letter variables 👌01:09:57
@klugmathias:matrix.org0.Eth3rnal_And this is ontopic, since it's a python library for math stuff which might be useful in blender :)01:10:31
@klugmathias:matrix.org0.Eth3rnal_ I haven't tested it in blender, I originally made it for my shell, but it should work fine 01:10:58
@akawama:matrix.orgAkawama joined the room.02:34:17
@akawama:matrix.orgAkawamaWhen I run blender with prime-run it says my gpu is not supported but when I run it with dri_prime=1 it runs fine. Why is that so?02:35:44
@neuroblossom:matrix.orgneuroblossomthanks for the ideas everyone i'm using the camera shifting method and it's way, way faster03:22:05
@neuroblossom:matrix.orgneuroblossomactually what i mean is, it's not crashing like it was03:22:20
@marisvaldo_amaral:matrix.orgMarisvaldo Amaral changed their profile picture.12:55:24
@nurpu:matrix.orgnurpu changed their display name from nurpu to k0r0va.13:55:12
@nurpu:matrix.orgnurpu changed their display name from k0r0va to nurpu.13:55:37
@maxicarlos08:matrix.org@maxicarlos08:matrix.org left the room.16:35:56
@akawama:matrix.orgAkawama * My GPU is incompatible with blender, only has 2.1 compute capability while blender requires 3.0+ so when I run blender with Nvidia prime render offload prime-run, it says my gpu is not supported but when I run it with Nouveau prime dri_prime=1, it runs fine. Why is that so?17:25:18

There are no newer messages yet.


Back to Room List