Juskelis
Level 1
|
|
« Reply #260 on: September 16, 2015, 12:45:52 AM » |
|
Anyone know of a way to reflect an angle A over another angle B? Something like Angle A | Angle B | Result | 10 | 5 | 15 | 20 | 350 | 50 | 270 | 300 | 240 |
I don't know if this is genuinely hard, I'm really tired, or I'm an idiot, but I can't figure this out for the life of me.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #261 on: September 16, 2015, 01:57:17 AM » |
|
Well, how did you calculate/find the results to your three examples here to begin with?
|
|
|
Logged
|
|
|
|
Rusk
Level 1
|
|
« Reply #262 on: September 16, 2015, 02:19:36 AM » |
|
Anyone know of a way to reflect an angle A over another angle B? Something like Angle A | Angle B | Result | 10 | 5 | 15 | 20 | 350 | 50 | 270 | 300 | 240 |
I don't know if this is genuinely hard, I'm really tired, or I'm an idiot, but I can't figure this out for the life of me. (2*A-B) % 360
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #263 on: September 16, 2015, 03:40:01 AM » |
|
Might have use for that depending on what you mean, exactly, by reflect? Rays of light?
|
|
|
Logged
|
|
|
|
indie11
|
|
« Reply #264 on: September 16, 2015, 03:55:44 AM » |
|
Anyone know of a way to reflect an angle A over another angle B? Something like Angle A | Angle B | Result | 10 | 5 | 15 | 20 | 350 | 50 | 270 | 300 | 240 |
I don't know if this is genuinely hard, I'm really tired, or I'm an idiot, but I can't figure this out for the life of me. (2*A-B) % 360 this fails for case 2 (2 * 20 - 350) % 360 => (40 - 350) % 360 => -310 % 360 = -310 ** NOTE ** Did you assume that 360 will automatically be added? that is when its 50
|
|
|
Logged
|
|
|
|
Dacke
|
|
« Reply #265 on: September 16, 2015, 04:37:47 AM » |
|
=> -310 % 360 = -310
This depends on the language. In some you get the same sign as the divisor and in others the same as the dividend. Check the table to the right: https://en.wikipedia.org/wiki/Modulo_operationThe most common one seems to be to use the dividend, in which case: -310 % 360 = 50
|
|
|
Logged
|
programming • free software animal liberation • veganism anarcho-communism • intersectionality • feminism
|
|
|
Rusk
Level 1
|
|
« Reply #266 on: September 16, 2015, 05:46:16 AM » |
|
This depends on the language. Really, I didn't know that. So let's hope Juskelis uses python, or I'm toast.
|
|
|
Logged
|
|
|
|
Juskelis
Level 1
|
|
« Reply #267 on: September 16, 2015, 11:39:00 AM » |
|
So let's hope Juskelis uses python, or I'm toast.
I think GML would break it, so I did the extra "if negative, add 360" bit, and it seems to work. Might have use for that depending on what you mean, exactly, by reflect? Rays of light?
I was going to use on a sword that I wanted to always swing through the aim direction. I'm pretty much trying to replicate this: I thought that reflection might help me out, but it hasn't really helped at all, I think? I'm surprised at how difficult this is for me to figure out.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #268 on: September 16, 2015, 12:18:31 PM » |
|
Nor sure I understand at all then. Why is it called reflection?
|
|
|
Logged
|
|
|
|
Juskelis
Level 1
|
|
« Reply #269 on: September 16, 2015, 01:07:34 PM » |
|
Nor sure I understand at all then. Why is it called reflection?
I thought in my 3am stupor that reflecting the sword over the aim would work
|
|
|
Logged
|
|
|
|
gimymblert
|
|
« Reply #270 on: September 19, 2015, 05:32:42 PM » |
|
In Python 3.x, try using the optional encoding argument of open; that usually gets me around all the trouble I used to have in 2.x with Unicode encoding errors. with open('utf8lines.txt','r', encoding="utf-8") as infile: with open('unique-lines.txt', 'w', encoding="utf-8") as outfile: unique_lines = set(line.strip() for line in infile) outfile.write("\n".join(unique_lines))
If you're in 2.x, you can import this version of open from __future__ C:\Python34\python.exe C:/Users/user/PycharmProjects/hellopython/ParseDictionaryToUnique.py File "C:/Users/user/PycharmProjects/hellopython/ParseDictionaryToUnique.py", line 37 with open('C:\Users\user\Documents\#1 ConceptNet Relations\dictionary.txt','r', encoding="utf-8") as infile: ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Process finished with exit code 1 EDIT: Wait I forgot to prefix as raw text EDIT2: CORRRRREEECCCTTTTTTTOOOOOOOOOOOOOOOOOOO!!!!!!!!!! Python wizard VALRUS
|
|
« Last Edit: September 19, 2015, 05:52:51 PM by Jimym GIMBERT »
|
Logged
|
|
|
|
Thorves
Level 0
|
|
« Reply #271 on: September 20, 2015, 04:48:40 AM » |
|
In unity, how would I make air resistance (drag) greater or smaller depending on the collision of movement? Let me try to illustrate what I mean: I'm making an airplane by the way. I notice that when I make a turn while flying, I'm suddenly flying sideways because the velocity does not change in direction.
|
|
|
Logged
|
|
|
|
Mittens
|
|
« Reply #272 on: September 20, 2015, 05:33:57 AM » |
|
you want to use the Dot product of the objects world space velocity and the planes forward vector (or whatever vector is the direction of the flat face). float dragginess = Vector3.Dot(rigidbody.transform.forward, rigidbody.velocity.normalized); then use that value to apply some counter velocity A dot product will return 1 when the two vectors are perfectly aligned, -1 when the vectors are perfectly oposite and 0 when they are at right angles to one another. Given that the value goes into negatives, for the purpose of air resistance, you'l want to add some code to keep it posative if(dragginess < 0){ dragginess *= -1f; }
|
|
|
Logged
|
|
|
|
BorisTheBrave
|
|
« Reply #273 on: September 20, 2015, 08:37:06 AM » |
|
The way drag is normally formulated is roughly: drag force = 0.5 * velocity * velocity * co-efficient of drag applied against the direction of motion. The co-efficient of drag represents the shape of your object and what cross-sectionaly area is shows, facing the direction of motion. Computing accurate values for this is not really feasible - drag is complicated. We could do some simple approximations which would suit several purposes and fix the effect you describe. Assuming that the wing is totally knife edged, then yes, you can indeed do something like: drag coefficient = max*abs(dot(velocity, wing up vector)) Which will give zero when flying straight ahead (or backwards) and max when pointing 90 degrees against the current direction. There's a lot more to flight mechanics than drag though - and I think this thread is too short to explain everything. When a pilot starts to turn the plane so the aircraft is pointing more away from its current velocity, it's not just drag that slows the plane down - some of the wing lift has the same effect.
|
|
|
Logged
|
|
|
|
Thorves
Level 0
|
|
« Reply #274 on: September 20, 2015, 10:22:04 AM » |
|
That worked very well, thanks!
And I know there's a lot more to it, and I'm currently figuring that out.
My wing lift is always straight up from the plane's perspective (transform.up) so when you make a 90 degree turn this force will indeed slow you down.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #275 on: September 26, 2015, 05:37:43 AM » |
|
If anybody wants to win a T-shirt by "bringing me as a friend" to https://www.biicode.com/, here's your chance. Does anybody use it? Is it good?
|
|
|
Logged
|
|
|
|
Layl
|
|
« Reply #276 on: September 26, 2015, 07:51:21 AM » |
|
If anybody wants to win a T-shirt by "bringing me as a friend" to https://www.biicode.com/, here's your chance. Does anybody use it? Is it good? I don't use it but "CMake on steroids" doesn't sound too appealing.
|
|
|
Logged
|
|
|
|
DragonDePlatino
|
|
« Reply #277 on: September 26, 2015, 11:18:11 AM » |
|
I am currently going through Lazy Foo's SDL tutorial, and when I got to this part I was confused. Why should I learn how do colorkey transparency in SDL when I can just load a transparent PNG? I know the former results in faster rendering, but isn't that negligible on modern hardware? And it can't do semi-transparency or edge anti-aliasing? I even downloaded the source for that tutorial, edited the stickman to have a transparent background and got the same result.
|
|
« Last Edit: September 26, 2015, 11:26:31 AM by DragonDePlatino »
|
Logged
|
|
|
|
Cheezmeister
|
|
« Reply #278 on: September 26, 2015, 01:19:54 PM » |
|
Yes, on modern hardware (with a modern version of MS Paint =P) there's little reason for color key transparency. I haven't used blitting in a while but I can only assume that SDL can handle alpha channels in a PNG. And after reading your second paragraph, clearly that is in fact the case.
Lazy Foo's tutorials have been around for a decade. You might ask him directly but I assume that's a legacy chapter.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #279 on: September 26, 2015, 01:32:14 PM » |
|
If anybody wants to win a T-shirt by "bringing me as a friend" to https://www.biicode.com/, here's your chance. Does anybody use it? Is it good? I don't use it but "CMake on steroids" doesn't sound too appealing. Just interested in the idea of trying out a dependency manager for C++. And it can't do semi-transparency or edge anti-aliasing?
No problems. Just save a PNG as usual — you seem to have figured that out already. To get good results when rotating sprites, you might want to set a higher value for this hint.
|
|
|
Logged
|
|
|
|
|