dacatchman Posted September 24, 2019 Share Posted September 24, 2019 If I just increment rotation (container.rotation +=1*dt) it increases indefinitely (ie: its not in radians), but it's listed as radians in the docs. It seems to just be a setter? How do I get the actual rotation of my object, and why is it obfuscated in such a fashion? Even inspecting the object and diggin into the matrix shows invalid rotation values. Right now I'm constraining it myself to radians, but that seems out of sorts (it changes nothing, except the value, anyhow). Obviously, internally, Pixi does this on its own, just curious where the real values are to use. I mean if I want to do vector math what am I supposed to do with a "radian" value of 2500 ? Quote Link to comment Share on other sites More sharing options...
mobileben Posted September 24, 2019 Share Posted September 24, 2019 What do you mean by "get the actual rotation"? rotation is both a getter and setter. https://github.com/pixijs/pixi.js/blob/812ff8a944e0c805b8afc16ebef5a5d6fba0c0c3/packages/display/src/DisplayObject.js#L597 It is radians. If you want the degree variant, you can use "angle". Using 2500 should be fine, but if you want, you can always reduce it down in size. BTW, it would probably be helpful if you showed a bit more code on how you created objects and are trying to rotate them. Quote Link to comment Share on other sites More sharing options...
dacatchman Posted September 24, 2019 Author Share Posted September 24, 2019 The code was provided, take a display object (container, sprite) and increment it's rotation indefinitely (see first line of OP). Then access the rotation property. The value is nonsensical. It's less of a coding question and more of a philosophical one? I mean this is a 2d library, according to itself. What use is rotation, declared in radians, past 2pi ? I mean normally we'd discuss negative radians, some people are all about -pi to pi, others may want 0 to 2pi. I get that discussion, you'd just use whatever the designer chose. But I don't understand this use case. Do people count how many times objects rotate? So you're telling me that's the normal use case, rather than me having to normalize/track my own rotations with an OpenGL library that internally uses a rotation matrix anyhow? heh. What purpose does it serve other than to (wildly unlikely) cause an Number overflow? Anyway, I don't mind doing it myself, it's just weird I have to... because reasons. I am curious what those reasons are, from a design standpoint. Maybe I'm just missing something, which is fair, so anyone, please correct me on that. Otherwise, I feel like this is just one of those oddities new users have to come across and cope with, when probably, they shouldn't have to. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 24, 2019 Share Posted September 24, 2019 > What use is rotation, declared in radians, past 2pi ? Yeah, You might want to ask creators of Adobe Flash and other renderers. Even those who use degrees work past 360 just fine. Do you have an experience with renderers that automataically set angle in (-pi, pi) or (0, 2pi) range? llike, obj.rotation = 361; if (obj.rotation === 1) { ... } Many things dont make sense for some people, but usually we copy behaviour from others or decide on something together. dacatchman 1 Quote Link to comment Share on other sites More sharing options...
dacatchman Posted September 24, 2019 Author Share Posted September 24, 2019 8 minutes ago, ivan.popelyshev said: > What use is rotation, declared in radians, past 2pi ? Yeah, You might want to ask creators of Adobe Flash and other renderers. Even those who use degrees work past 360 just fine. Do you have an experience with renderers that automataically set angle in (-pi, pi) or (0, 2pi) range? llike, obj.rotation = 361; if (obj.rotation === 1) { ... } Many things dont make sense for some people, but usually we copy behaviour from others or decide on something together. So to answer about other engines, matter.js does, phaser does. These are just some I looked at recently. PIXI is the oddity in my mind, but I don't play with engines all that often; the behavior was unexpected from me and so I was just curious if there was some use case I missed. I never used flash or action script, but those are dead now right? Background isC/C++ mostly. Thanks for replying, appreciate it. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
mobileben Posted September 24, 2019 Share Posted September 24, 2019 32 minutes ago, dacatchman said: The code was provided, take a display object (container, sprite) and increment it's rotation indefinitely (see first line of OP). Then access the rotation property. The value is nonsensical. It's less of a coding question and more of a philosophical one? I mean this is a 2d library, according to itself. What use is rotation, declared in radians, past 2pi ? I mean normally we'd discuss negative radians, some people are all about -pi to pi, others may want 0 to 2pi. I get that discussion, you'd just use whatever the designer chose. But I don't understand this use case. Do people count how many times objects rotate? So you're telling me that's the normal use case, rather than me having to normalize/track my own rotations with an OpenGL library that internally uses a rotation matrix anyhow? heh. What purpose does it serve other than to (wildly unlikely) cause an Number overflow? Anyway, I don't mind doing it myself, it's just weird I have to... because reasons. I am curious what those reasons are, from a design standpoint. Maybe I'm just missing something, which is fair, so anyone, please correct me on that. Otherwise, I feel like this is just one of those oddities new users have to come across and cope with, when probably, they shouldn't have to. Okay, sure you provided some code, but the reason I asked about more code was to better understand how you set it up primarily since you indicated you were getting invalid values. I think that's pretty much standard practice and if you posted to say SO, I would guess someone would invariably ask you the same thing. Regardless of if you use degrees or radians, you would be faced with "out of bounds" numbers. At least for my code, I always 1. work in radians within the engine and 2. adjust for when the value falls out of bounds. Note there are times I actually do use degrees. That could be when coming from a tool that exports the data, but where we find that occasionally we manually tweak values during experiments. However, it will be corrected once it goes into "runtime". Also keep in mind, you can use "angle" instead of rotation. If you look at the code, it just does the math for you to cover to radians. FWIW, I'm a C++ guy. But I also have used Flash and Actionscript as part of my tool chain. I always have method for dealing with degrees or radians (explicitly named as such) but as mentioned, game engine itself uses radians. I'd say more often than not, most stuff I've encountered uses radians. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 24, 2019 Share Posted September 24, 2019 Those frameworks/libs have their own math. Pixi math module is tiny and we dont focus on it, we leave it to people to make whatever they want. No Vec2/Vec3 math. No add() sub() and other small functions because pixijs doesnt need that. For example, I was pro-degrees that we convert everything to degrees - that failed, we added `angle` prop instead, and inside its still backed by radians which can trigger some strange behaviours when you try to serialize elements. You can set `Object.defineProperties(DisplayObject.prototype, 'rotation', {your getter/setter});` , its fine to hack pixi. mobileben 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 24, 2019 Share Posted September 24, 2019 Anyway, welcome to the forums! Make sure to go esotericsoftware.com/forum/ next and ask them why Spine runtime have swapped "b" and "c" in matrix fields. It also doesnt make sense, im telling it each time I dive into code. I certainly appreciate talks like that, not every thread has to be about "help me im stuck" Quote Link to comment Share on other sites More sharing options...
dacatchman Posted September 25, 2019 Author Share Posted September 25, 2019 17 hours ago, ivan.popelyshev said: Those frameworks/libs have their own math. Pixi math module is tiny and we dont focus on it, we leave it to people to make whatever they want. No Vec2/Vec3 math. No add() sub() and other small functions because pixijs doesnt need that. For example, I was pro-degrees that we convert everything to degrees - that failed, we added `angle` prop instead, and inside its still backed by radians which can trigger some strange behaviours when you try to serialize elements. You can set `Object.defineProperties(DisplayObject.prototype, 'rotation', {your getter/setter});` , its fine to hack pixi. I actually like that about PIXI, I just wanted a fast drawing lib with not a ton of addons -- not all that easy to find actually. Using defineProperties is a good suggestion I hadn't thought of, thanks. 17 hours ago, ivan.popelyshev said: Anyway, welcome to the forums! Make sure to go esotericsoftware.com/forum/ next and ask them why Spine runtime have swapped "b" and "c" in matrix fields. It also doesnt make sense, im telling it each time I dive into code. I certainly appreciate talks like that, not every thread has to be about "help me im stuck" For what it's worth, I wasn't trying to start problems or offend anyone, I was trying to ascertain if it was intended or a bug. My apologies. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 25, 2019 Share Posted September 25, 2019 > I actually like that about PIXI, I just wanted a fast drawing lib with not a ton of addons -- not all that easy to find actually. Using defineProperties is a good suggestion I hadn't thought of, thanks. Yes, that's why we are popular. > For what it's worth, I wasn't trying to start problems or offend anyone, I was trying to ascertain if it was intended or a bug. My apologies. I was not offended, I was trying to joke, my irony is rarely understood by anyone Quote Link to comment Share on other sites More sharing options...
b10b Posted September 25, 2019 Share Posted September 25, 2019 20 hours ago, dacatchman said: Do people count how many times objects rotate? Fair question. I'm not actually sure of the philosophical truth about 2D representations of rotations >2Pi? But from a pragmattic gamedev perspective I often want to know full rotations. Or rather I like to know whether a rotated value has rotated "more" than a previous one. In other words, I expect that when incrementing a value the result goes up (rather than potentially going down). And vice-versa for decrements. Fortunately modulo to 2Pi for resolving back to the expected range doesn't seem expensive these days? That being said I avoid relying on the rendering-engine to "own" such model data (for non-rendering purposes) and prefer to use a little helper class to answer such comparisons. I also avoid Radians (and Degrees), but that's off topic. So ... maybe you're right and ranges beyond 2Pi have no value (to me) in a rendering library? dacatchman 1 Quote Link to comment Share on other sites More sharing options...
dacatchman Posted September 25, 2019 Author Share Posted September 25, 2019 28 minutes ago, ivan.popelyshev said: > I actually like that about PIXI, I just wanted a fast drawing lib with not a ton of addons -- not all that easy to find actually. Using defineProperties is a good suggestion I hadn't thought of, thanks. Yes, that's why we are popular. > For what it's worth, I wasn't trying to start problems or offend anyone, I was trying to ascertain if it was intended or a bug. My apologies. I was not offended, I was trying to joke, my irony is rarely understood by anyone Haha. It's hard in text to see humor, especially across speakers of different languages. I am often seen as rude in text, but I'm usually just thinking outloud and wondering, not trying to bother anyone, but somehow doing just that. I'm quick to apologize for that reason =D Thanks again ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 25, 2019 Share Posted September 25, 2019 > Haha. It's hard in text to see humor, especially across speakers of different languages. Tell me about it ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.