first of all, its probably simpeler to create a locator and rotate that toward your desired direction/axis and parrent whatever object you want to it and (local)rotate the locator.
for a more exact mel sollution
i have to be honest and tell you that my knowledge of linear algebra is very basic…allmost non exixtent so i will make some mistakes but maybe you get some idea’s out of it.
the angleBetween command takes an -euler flagg to output 3 rotations for x y and z in degrees and it does take, like you said input from 2 directional vectors.
the problem is we don’t have any vectors, we only have two vertices, we can calculate a vector between those two vertices by subtracting them from eachother then we have an directional vector for our axis.
now we only need another vector to define the base axix where we want to calculate the angleBetween from. i ASSUME you are probably wanting to know the rotation in relation to your ground planeand i also assume that the object has zero rotation to begin with, else you’ll need another reference plane, so take the previously calculated vector and set its upaxis value to zero
(EX: if our previous vector was [1.2.3] we could set the upaxis (y) to 0 so the resulting vector would be [1.0.3]
i am not very wel versed in mel so regard the following as pseudocode
//somehow input or capture or select the name of the object for who you want
//its rotational axis set
string $objectName //input name here
//get input for the two coordinates, i assume you use vertices but locators are possible too
//calculate your vectors
vector $rotationAxis= `$vertex1 - $vertex2`;
vertor $baseAxis = <<$rotationAxis, 0 $rotationAxis >>;
//calculate the euler rotations to rotate $baseAxis into $rotationAxis
$rotations = `angleBetween -euler -v1 $baseAxis -v2 $rotationaxis`;
//set the rotation axis
xform -a -os -ra $rotations $rotations $rotations $objectName;
//you could also use
//select -r ($objectname) + (".rotationAxis");
//rotate -a -os $rotations $rotations $rotations;
this code will not run due to lazyness on my part, but you’ll get the general idea