![]() ![]() ![]() Make sure you’re running Unity 2017.1 or newer. As this tutorial is also based around the DistanceJoint2D you might want to review Physics Joints in Unity 2D as well and then return to this tutorial.ĭownload the starter project for this tutorial and open it up in the Unity editor. If you need to level up your Unity skills, work through our tutorials on Getting Started with Unity and Introduction to Unity Scripting first. Maybe it can be shortened.Note: This tutorial is intended for an intermediate to advanced audience, and won’t cover things such as adding components, creating new GameObjects scripts or the syntax of C#. Sorry for any mistakes, I've just written it down and haven't really tried it. The new endpoints are already there: E1' and E2'. We'll stick to NO for the remaining steps though.Ħ) Normalize NO and calculate the offset points: E1 + NO*k = E1' and C1 + NO*k = C1', where k is the offset.ħ) Repeat 5) with cross(N, D2) and cross (N, D3)Ĩ) Using the offset control points, you can now calculate the intersections in order to find the actual new control points. "Inwards" is just cross(N, D1) * -1 or simply cross(D1, N), as the cross product is anti-commutative, let's call that NI. C1-E1, C2-C1, E2-C2.ĥ) Calculate cross(N, D1), which produces another normal for the span of N and D1, that one would point "outwards", so let's call it NO. Make sure V1 and V2 are linearly independent before you continue.Ģ) Calculate cross(V1, V2), which produces N (upwards in your example), the normal that's perpendicular to the span of V1 and V2.ģ) Choose an order, for example E1, C1, C2, E2.Ĥ) Calculate the differences (the direction from one to the subsequent) in that order, i.e. Using the initial example with 2 endpoints, 2 control points:Įndpoint E1, Endpoint E2, Control point C1, Control point C2.ġ) V1 = C2 - E1, and V2 = C1 - E1. If that worked, you could simply use transforms in order to make life easier. I'm wondering if duplication of the points + scaling them propotionally would yield the results you're looking for. I'm not entirely sure that'd work though. If you want to do that for curves that do not just lie on a plane, it seems that you could just get the result by applying the method to 3 connected points at a time, from which you could always build a plane and its normal vector. Then, calculate the intersections in order to get the new control points. Using the direction of the lines which connect the points as well as considering the plane's, you should actually be able to determine the direction vector which is required to move the connecting lines in-/outwards. It appears to be the curve just with an offset though.įor the method described, and for the example at hand (endpoints and control points being on the same plane) you already have the plane on which the new points have to lie. It seems that you moved the new control points in the wrong direction. Now that's a little clearer, though I had to look up the Tiller-Hanson method. I may have also stumbled a bit here in trying to make things clearer, so if anything seems wrong/unclear please don't hesitate to ask! Strictly the desired behaviour here is more simply, i just require the new offset lines to be on the same plane just offset to the originator lines.Īpologies for not making things clearer. I thought it would be a good idea, just so I feel like I can learn manipulation of angles and perpendicular lines, that I could have a slider that when creating the offset lerps to change which perpendicular vector I am using for the creation of the parallel bezier curve. These are found by finding the intersection of the offset lerps from the original curve. The white shapes represent where the control and anchor points of the new curve would be. Using the cross product to get the perpendicular angle does not create the desired behaviour. I want the offset of the new curve to be on the same plane as the lines that make up the original bezier curve. Right now when I am using the cross product it is projecting the anchor and control points on a plane separate to the plane that the origin lines exist in. I want to be able in order to help make make this parallel bezier path creator and find. I thought, and I may be wrong, that those points have the constraint of having to come from the same plane, and the infinite number of perpendicular vectors is infinite in the same way that there are an infinite number of degrees in a circle. I thought that, give two points and a vector which describes the line those two points, there would be an infinite number of perpendicular points coming any given point on that line. I'm trying to code a parallel bezier path using the Tiller-Hanson method. ![]()
0 Comments
Leave a Reply. |