Hi,
I have 2 lines which are in the same layer, what I want to do is calculate the angle between the 2 lines. How could I do this in c#? I have the 2 Line objects within my code.
Is there a command or method I could use to get the angle between the 2 lines?
Below is an image of the 2 lines which I want to get the angle of.
if both lines have share the same origin and are pointing away from this origin you could get their direction vectors (their tangents) and use them to calculate the angle using Rhino.Geometry.Vector3d.VectorAngle
First, the angle the method returns is in radians, so you’ll need to convert it to degrees.
Second, if you do not provide a proper plane, it can be that you’ll get the reflex angle, which you have to subtract from 180 degrees. This seems to be the case here, 2.059 in radians equals 117.97201 degrees, once you subtract it from 180 you’ll get 62.0279 degrees.
You’ll might also try to use the method which allows to define a plane. Using a plane normal as a third vector technically allows to get a signed angle. The math behind should be something like below function, which is python btw:
def GetSignedAngle(Va, Vb, Vn):
'''gets signed angle between Va and Vb, Vn is the plane normal'''
# all vectors must be unitized
cross = Rhino.Geometry.Vector3d.CrossProduct(Va, Vb)
# angle in radians
return math.atan2(cross * Vn, Va * Vb)
Hi,
Sorry to be a pain and resurrect a dead thread but this is the most appropriate starting point from my POV (a beginner).
I am also looking to measure the angle between two lines, very similar to this, however, these lines originate from objects that interact with each other (whole different issue) and change the angle dynamically. I am looking to measure the maximum angle that could be achieved between these two objects at their point of contact.
Is there a way I could read this angle automatically and have it return the values?
For context, these two objects are caudal (tail) vertebrae of a dinosaur, and I am measuring the maximum tail flexibility that the dinosaur could achieve. As such, on a vertebrae to vertebrae basis, there would be contact points that prevent full 360 rotation, such as contacting neural spines, caudal ribs, haemal spines etc. I have attached an image of my work thus far as I have already created these objects in blender and I am now onto the next step of measuring these angles given certain parameters. I am looking to use Bend tool as rigid as to not deform these bones and then prevent the angle changing beyond the point in which these two bones contact, then measure that angle so that I can plot it on a graph. Without this being an option I would need to take 15840 readings for the entire tail, so this would save me a huge amount of time.