Rotation around center of mass is weird.
-
Im drawing a star and trying to rotate it around its center of mass without including the gradient in the rotation. At lower point counts its alot more obvious whats going on. For some reason at higher point counts its stable. hmmmm

If anyone else wants to give it a go.. Thank you!
MyKnobLaf.registerFunction("drawRotarySlider", function(g, obj) { var a = obj.area; var range = obj.max - obj.min; var stableSize = a[2] * (1.0 - 2.0 * 0.15); var ox = a[0] + (a[2] - stableSize) / 2; var oy = a[1] + (a[2] - stableSize) / 2; var cx = ox + stableSize / 2; var cy = oy + stableSize / 2; var sw = stableSize / 200.0; var startOffset = 2.5; var totalSweep = 2.0 * startOffset; var endOffset = -startOffset + totalSweep * (obj.value - obj.min) / range; // ============ COLOUR CONTROL ============ // -- Star Body 3 -- var cStarBody3Top = 0xff888888; var cStarBody3Bot = 0xff333333; // -- starBody3 -- var starBody3Size = stableSize * 0.8; var starBody3Star = Content.createPath(); starBody3Star.addStar( [0.5, 0.5], 3, 0.42, 0.5, endOffset ); starBody3Star.roundCorners(1); var starBody3Area = [cx - starBody3Size * 0.5, cy - starBody3Size * 0.5, starBody3Size, starBody3Size]; g.setGradientFill([cStarBody3Top, cx, cy - starBody3Size * 0.5 + starBody3Size * 0.5 - starBody3Size * 0.5, cStarBody3Bot, cx, cy + starBody3Size * 0.5 + starBody3Size * 0.5 - starBody3Size * 0.5, false]); g.fillPath(starBody3Star, starBody3Area); });I Cant figure out why the shape warbles when
-
@Chazrox you need to use
starBody3Star.getBounds(multiplier)as drawing area. Complex shapes manage their own area, that is dynamic so it can hold the entire shape without being distorted.
A star doesn't fit in the same square as you rotate it. It needs to grow, shrink, and translate dynamically.
In your code you force it to draw in a fix square, so the shape adapts... -

HiseSnippet 1490.3ocsW0raaaDDdosYSrZSPCPO0SK7IYGIZJZKGaXDDG+iZMh+qVNAsHvHcE4RoslZWAxUwRsn.8cnuL8XN1mhh9.zC8RO2N6RJxk1JNIFM7fD2Y9lc9lY2Y4rmDK7oIIhXjUkyFOfhr9L61i4xd6ziv3n82EYce6CIIRZLNU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pEqjpSNpy4RVfr2RtNq0bQGITYkDAavBtt9FOpYM7zjt3lps74lh6LFN9q9kKtrGTMiuPUJyjXeX2aLMnx72TZ3pgdQ3lGpB9QBI8XdZTB4A7UUEFNUcpJnXQTDMdppUs6DeSFVkOreGJPR8AR4.gOoWtOA62deBlsw3mVPa.Tv2myjGOfxeaM2fxNE.5oXlLVAPk5NJteVGEoepCwfFGtistLBoIbVqbu4ep9WOA8darWIi+yu429imfd996RjDUeMYzAn3.ZrjohdqcouF5pLsKm4s2klbgTL.RR48P.888NY7nhFO+tsFWLfskdemofdT0wIlRPe.txyvUuIdptx152ggSbS5HSWb2TWbuLWb.oCMR6g6Zqe2LZ9EhgK156KbwnRtnELRRGAu+k15yrvDcoeROx.JlDPFHSPgPxWc5hYO5eH7xLz2Z3sjWZFUSSuajWWuCXn2aQvP3.ixMjqt1RlBn5qTWvpNc4IL4Xyq07+VW5uuT7A1mvj98lNGmYJbTUr9QfiY2s4d16EFBGUVPv4ra8sebtHC5TwPIi28PhLlAadrOZX+1vmz8of24b36wpMIynJORG6pFqx.sgdIzC9W3ISYC0XqLkMlnD0m3GKdke5ATpaOcWsDfSb8MMmGtxKLFW9XM8Se3xbux2u7TcMC8tsFtxs0vUusF171Z3Z2VCezs0v0e2Fptq8SGJE8SKaPnCOYO8WRrr1iq5CVuaE8efZb2RJ -
@Chazrox It's even more obvious with 3 branches:

I love this one because it reminds me of the Wankel engine


-
@ustk Thank you! You're a beast.

@ustk said in Rotation around center of mass is weird.:
the Wankel engine
hahaha

-
@ustk I get error : unknown function 'translated'. Is this a new function I dont have??
-
@Chazrox said in Rotation around center of mass is weird.:
I get error : unknown function 'translated'. Is this a new function I dont have??
It's part of the rectangle class.
https://docs.hise.dev/scripting/scripting-api/rectangle/index.html
-
@David-Healey I see it in my api list but its not working in this snippet for me.
-
-
@David-Healey Goooot it.
Thank you sir. I didnt read enough. Will do better. ha. -
@ustk Working and looking great! Thank you big time!

This is the shape i've been after for a while because I want to make analog knob shapes. This helps so much. Thank you.
Thank you @Christoph-Hart for the new api as well! Sick.

-
@David-Healey Im embedding this exact warning in my knob designer so people will know this if they dont.

