#๐ Help me optimize my cloth sim :)
27 messages ยท Page 1 of 1 (latest)
@high gull
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste @high gull
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Yeah sorry lol
I forgot i couldnt send files
the Vector class is defined like this btw
class Vector:
def __init__(self, x, y):
self. __rmul__ = self.__mul__
self.x = x
self.y = y
def get_length(self) -> float:
return ((self.x**2) + (self.y**2))**0.5
def normalize(self):
length = self.get_length()
if length == 0: length = 0.001
return Vector(self.x/length, self.y/length)
def __str__(self):
return "Vector("+str(self.x)+","+str(self.y)+")"
def __mul__(self, other):
if isinstance(other, Vector):
return self.x*other.x + self.y*other.y
elif isinstance(other, int) or isinstance(other, float):
return Vector(x=self.x*other, y=self.y*other)
else:
raise TypeError("Cant multiply vector with",type(other))
def __sub__(self, other):
if isinstance(other, Vector):
return Vector(x=self.x - other.x, y=self.y - other.y)
else:
raise TypeError("Cant subtract vector from",type(other))
def __add__(self, other):
if isinstance(other, Vector):
return Vector(x=self.x + other.x, y=self.y + other.y)
else:
raise TypeError("Cant add vector with",type(other))
I wouldn't be surprised if there's nothing to do to optimize it lol
But i made it for fun anyway so its whatvr
yeah being a little more specific might help, just sending a bunch of code with a message "optimize it" doesn't sound too nice
mb :P
might aswell ask AI do that ๐
i did highkey lmao
and if that fails and you are desparate and need optimization then ask
i did :P
what'd it say
It tried using multiprocessing and crashed hella
is that all it suggested? multiproccessing is like a last resort unless you have a massive app
but im pretty sure your app isn't massive
it isn't i sent the whole code
welp, I'm too h... sleepy to look for improvements
you could just wait around here, maybe someone will help
unlikely though
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.