#find vector
1 messages Β· Page 1 of 1 (latest)
- find a method that will rotate a vector
- get the vector from point 2 to 1 = point1 - point2
- rotate that vector by 60 degrees
- normalize the vector and multiply it by your magnitude (5)
- this new vector with right length, you now add to point 2 and that will get you point 3
I think it should be point2-point1
also why should I rotate point2-point1 vector
?
point2-point1 this would give the vector from point1 to point2, which isn't what I said,
imagine like a pendulum, you swing the vector point2ToPoint1 around point2 so point2 has to be the origin
why? because it exactly gives you the direction of the vector you ask for?
to get the vector from p2 to p3 is literally
take the vector p2 to p1,
rotate it by 60 degrees,
change the magnitude to 5
well actually both would work, but if you do it with (point2-point1), you need to negate the angle in a way (-60) and also change the sign of the vector (invert it later) again
sounds more complex, would work too, but why go through that effort
thanks, your pendulum analogy cleared it.
thanks !
just to be clear
this is what are you saying... right?
I think it should be y=60 π
it's in 3d=
?
well not that it matters much
after you calculated myVector, you miss the step where you add the second point to it
if you want it to be relative to point2
and i dont get your angle check
why do you use point2ToPoint1 as rotation base vector but then compare the angle against point1ToPoint2? after you applied the rotation
i don't know your project so i dunno which axis you need
if it's 2d it is likely the z axis
but for 2d you can look up simpler algorithms to rotate a vector2 i believe
(well simpler in terms of processing, not really in terms of code). doesnt really matter though, quaternion multiplication should be fine
I am just forcing the c point (cube) to have atleast 60degree angle
if its less than 60 then make it 60
that kind of logic
if its more than 60 don't do anything
ah I see, so you need the x rotation in that case
I am still confident that my suggested logic should be fine
for your initial question
lemme try to rotate on x axis. for now I am getting bizzare result from the code π . must be me doing something wrong
if L should be below, maybe try to invert the angle (angle * -1f)
or just adding the minus in front
in your screenshot looks like it should be z but it can also be that you have local axis transformation movement enabled, which would show the local axis gizmos, not the global ones
wait lemme send a full screenshot
its from top view
and indeed its set to local
ah yeah local
okay, so from the global gizmos, seems like you look for the y rotation
z is up, x is right,
so y would be the depth axis
yeah, I am using y axis but some reason the code is giving wrong vector.
the point you mentioned to add second point
I didn't get that
but lemme try anyways
now it looks fine?
yeah, just that the angle check makes 0 sense
yeah, omit that part π
before you added point 2, you had a relative vector (imagine as if it had the origin of (0,0))
now you have the absolute point 3
but then you compare the angle of some point to point vector, which you also inverted, to a point (you'd need 2 relative vectors)
sorry i already started typing, just for clarification ^^
does rider show all the values like that? that's neat