#Quick question what is the non dumb way

1 messages ยท Page 1 of 1 (latest)

mossy falcon
#

.

#

do you want rotate at position pivot?

tacit shuttle
#

I want to rotate position around pivot x number of times.

mossy falcon
#

that is rotate around

tacit shuttle
#

@violet heart yeah, but using uniy's mathematics package.

violet heart
#

oh, ok then

tacit shuttle
mossy falcon
#

you must find relative rot, pos

#

and apply at later

gray spindle
#

Please at least read their question before answering lol

#

It is clearly not using transforms

mossy falcon
#

var rotRelative = Quaternion.Inverse(B) * A;

mossy falcon
#
  1. find rotate relative with Quaternion inverse(B) * A
violet heart
#

@tacit shuttle you actually make relativePosition the same times amount of times

float3 relativePosition = position - pivot;
tacit shuttle
#

Let me try to give more context. I have a list of equality distant points. And I need the points to stay equality distant.
The only way I have found to do that while applying a rotation is to apply the rotation multiple times for each point. So rotate it once for the first point, 2 times for the second, 3 times for the third, etc.

violet heart
mossy falcon
#

this my code. you can convert it

#

you must find rot relative, local pos offset
and apply it

tacit shuttle
mossy falcon
#

try my code and convert to native code

tacit shuttle
#

This is what I am doing for context

mossy falcon
#

IK ?

tacit shuttle
#

No, IK is different

mossy falcon
#

ok haha

#

can you read my code bro

#

i think is ez for you

tacit shuttle
#

Your code is not relevant to the issue.

#

It is totally different

mossy falcon
#

why

tacit shuttle
#

I need to 'multiply' a quaternion rotation by x. That is my issue

mossy falcon
#

oh wait

#

my code is just solve relative rotate around by pivot

#

so do you want do rot around by pivot at X time?

#

// I want to apply the rotation multiple times. I feel like you should be able to do something like rotation * times and get the same result. But, maybe I am wrong and just not thinking of it properly.

tacit shuttle
#

Yeah

mossy falcon
#

so i want scatter
example do you want rotate obj range box
from origin

#

call func dRotate(pos, pivot,rot = 45 angle, count = 2)

#

is correct?

tacit shuttle
#

Yes, that is correct

mossy falcon
#

oh ok is ez bro haha

#

wait for my code one minut

violet heart
tacit shuttle
violet heart
#

try to print it and you gonna see it

violet heart
#

so maybe you can provide a better way for your code for us to understand what should it execute?

mossy falcon
#

i have question

#

args rotation is var from angle degree?

#

Quaternion rotation

tacit shuttle
# violet heart so maybe you can provide a better way for your code for us to understand what sh...

Yeah, here is just the actually code. Chain is basically just a list of float3 + quaternions

// This is the one that I want smoothly create acurve from fromIndex to toIndex.
public static void SmoothRotate<T>(this T chain, int fromIndex, int toIndex, quaternion rotation)
            where T : IChain
{
  for (int i = fromIndex + 1; i <= toIndex; i++)
  {
      // This is really ugly looking to do and not very great performance wise.
     Rotate(chain, i, rotation);
  }
}

// This rotates a single point, all points after keep there relative position.
public static void Rotate<T>(this T chain, int index, quaternion rotation) where T : IChain
        {
            ChainNode targetNode = chain[index];

            // Reposition all of the points down the chain from the specified index.
            for (int i = index + 1; i < chain.Count; i++)
            {
                ChainNode node = chain[i];
                float3 relativePosition = node.Position - targetNode.Position;
                float3 rotatedPosition = math.mul(rotation, relativePosition);

                node.Position = targetNode.Position + rotatedPosition;
                chain[i] = node;
            }
        }
violet heart
#

yeah, wait

#

it quaternion smth additional that I we do not know?

#

not Quaternion?

tacit shuttle
#

like math.mul(rotation, relativePosition); is rotation * relativePosition

violet heart
tacit shuttle
violet heart
#

or you cannot do that in this case?

tacit shuttle
#

It does the same thing

mossy falcon
#

hey bro

#

the 2 obj is will need rotate identify

tacit shuttle
violet heart
#

wait, so it does not work

#

but you do this in Unity, right?

tacit shuttle
violet heart
#

but you do this stuff in Unity?

tacit shuttle
#

Yeah

violet heart
#

I wonder why you do use float3 then, but ok

tacit shuttle
mossy falcon
#

him use jobs system

gray spindle
#

Hmm have you tried multiplying the rotation by another rotation?

#

Like if you added to the rotation between each iteration

#

If this is confusing then just nvm, I mightve misunderstood. But I think I understand what your current code does

#

Maybe something like rotation = mul(rotation, rotation) between each iteration or is that crazy?

mossy falcon
#

obj 1 bettwen obj 2 is be child, parent?

#

or not?

tacit shuttle
gray spindle
#

I made a quick prototype

#

(Its animated kinda like yours but i cant be arsed to record)

#

I tried with Quaternion * Quaternion first but got similiar results to your most recent GIF @tacit shuttle

#

Incrementing a float for the angle works better

#

This is just what I threw together for testingcs float angle = 0f; var pos = Vector3.zero; var positions = new Vector3[10]; for (int i = 0; i < 10; i++) { positions[i] = (Vector3) Event.current.mousePosition - pos; Quaternion rot = Quaternion.Euler(0, 0, -angle); angle += 60f * Mathf.PingPong(GGTime.GetUITime(), 1f); pos += rot * Vector3.up * 25f; } Handles.color = Color.red; Handles.DrawAAPolyLine(5, positions);

#

Lemme know if theres something I need to clarify and/or if this is even what you wanted

#

Really the key part here is just this Quaternion rot = Quaternion.Euler(0, 0, -angle); and incrementing the angle in each iteration

mossy falcon
#

my case img1 original obj

#

img2: after rotate

gray spindle
mossy falcon
#

simple solve just make rotate around with pivot
and rotation == apply rotationEulerAngle * count

#

is correct?

gray spindle
#

Heres a cleaner version of minecs var positions = new Vector3[10]; var pos = Vector3.zero; var rotAdd = Quaternion.Euler(0, 0, anglePerPoint); var rot = Quaternion.identity; for (int i = 0; i < 10; i++) { positions[i] = pos; rot = rotAdd * rot; pos += rot * Vector3.up * 25f; }

#

(I'm doing this in UI space obviously but you get the point)

#

I guess that anglePerPoint here would come from your rotation gizmo

mossy falcon
#

@tacit shuttle are u sleep bro haha

tacit shuttle
# gray spindle Heres a cleaner version of mine```cs var positions = new Vector3[10]; var pos = ...

Hmm, thanks for this. And after thinking about it more, and looking at this. I realized it isn't just a rotation issue but a position issue. Like, yours works, but also requires you to override the position completely.
So, while keeping the offset, I am not sure there is a good way to do it without just looping over them all multiple times like I am. Well, I guess you can probably do the math for the loops instead.

tacit shuttle
mossy falcon
#

chain IK?

tacit shuttle
# mossy falcon this case?

The thing with this type of implementation is that the distance between the points no longer stays equal. I appreciate the effort though ๐Ÿ™‚

mossy falcon
#

distance is must equal?

#

oh wait

mossy falcon
tacit shuttle