question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Absolute scaling of circle body

See original GitHub issue

Is there any possibility to scale circle with absolute value? Body.scale method is relative to current size. I have to scale it down, and then scale it back to initial size. I could do the math to reverse the scaling, but in this case the value depends on object position.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
liabrucommented, Apr 2, 2021

One thing to know is that unlike in a graphics engine, bodies keep their own geometry absolute in world-space for performance reasons, as well as to simplify the overall implementation.

So if you need some sense of ‘absolute scale’ you should keep track of all scaling applied relative to the initial scale. In other words every time you scale the body using Body.scale(body, scale, scale), also keep track of that by scaling a stored scale factor at the same time e.g. body._currentScale *= scale.

Then to revert to the original scale for example, you can do this:

Body.scale(body, 1 / body._currentScale, 1 / body._currentScale);
1reaction
inearcommented, Mar 31, 2021

I also needed to scale the body, and with easing, which was to complex math for me. Solved it for any shape (single part only) by storing two copies of the vertices-array. One with the original and one with manipulated values. In the animation, gasp I’m my case. I multiply the original vertices with a scale-factor and save to the manipulated array (by index to avoid creating new arrays each frame). Then set the vertices on the body. Then finally applying rotation on the vertices to the same as the current body.angle, because body rotations are changing it’s vertices.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Absolute Scaling - Foundry Learn
Absolute Scaling allows you to determine the dimensions of your mesh and then rescale it uniformly, explicitly or in reference to the dimensions...
Read more >
Absolute Vs. Perceptual – Chelsey Cu - UBC Blogs
Absolute scaling is when the size of the circle is in direct proportion to the value of the data. So, a city with...
Read more >
Mohr's circle - Wikipedia
Mohr's circle is a two-dimensional graphical representation of the transformation law for the Cauchy stress tensor. Figure 1. Mohr's circles for a ...
Read more >
The relative error % of the absolute scale estimate as a ...
The relative error % of the absolute scale estimate as a function of the rotation angle θ. Comparison between the linear 3-point method...
Read more >
Responsively scale an absolutely positioned element
Below is the CSS I applied to the image. .upper-partial-circle { position:absolute; z-index: 1; left: -10%; max-height: 300px; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found