Answered by
8 years ago Edited 8 years ago
Unfortunately I don't quite understand the specifics of the problem, but one thing I can see is that you're missing one of the key rules of welds :P
The rule of thumb is that welds satisfy this equality:
1 | part 0. CFrame * c 0 = part 1. CFrame * c 1 |
This might make you think that you can easily solve for c0 or c1 by dividing both sides by either part0.CFrame or part1.CFrame. The problem is that this isn't normal algebra, it's linear algebra and matrices don't have a division operation.
As a result we instead have to use the inverse instead. In linear algebra this matrix has the unique property of multiplying against the original matrix and returning the identity matrix. Now the important thing to keep in mind is that matrix multiplication is not commutative meaning A * B != B * A. Luckily for us pre-multiplying and post-multiplying by the inverse returns the same result A^-1 * A = A *A^-1 = I.
I probably confused you pretty bad so in summary all I'm saying is that:
- Exceptions may apply due to float math errors but this would hold true given a perfect calculation.
2 | print ((A * A:inverse() = = A:inverse() * A) = = CFrame.new()); |
Anyway moral of the story here is that when using the inverse to solve for c0 or c1 the order matters. If I pre-multiply on one side I have to pre-multiply on the other and vice versa.
Eg. I can't post-multiply to solve this:
1 | part 0. CFrame * c 0 = part 1. CFrame * c 1 |
2 | part 0. CFrame * c 0 * part 0. CFrame:inverse() = part 1. CFrame * c 1 * part 0. CFrame:inverse() |
b/c idk what c0 is and therefore can't multiply it against part0.CFrame:inverse() or part0.CFrame. In other words I've added some variables and by no means made it easier for me to solve this.
If on the other hand I pre-multiply I'm able to single out either c0 or c1
1 | part 0. CFrame * c 0 = part 1. CFrame * c 1 |
2 | part 0. CFrame:inverse() * part 0. CFrame * c 0 = part 0. CFrame:inverse() * part 1. CFrame * c 1 |
3 | CFrame.new() * c 0 = part 0. CFrame:inverse() * part 1. CFrame * c 1 |
4 | c 0 = part 0. CFrame:inverse() * part 1. CFrame * c 1 |
Usually unless we specifically need it for something c1 is set to CFrame.new() meaning:
1 | c 0 = part 0. CFrame:inverse() * part 1. CFrame |
So there you go! You now can manipulate welds to solve so that they maintains the constraint between part0 and part1's world space at the time of using the above equation(s).