I'm not sure I understand the requirement for a line length, but your implementation (while valid) shouldn't require angles..
I'll replicate your solution from the comments and explain:
Explanation
float offX = startX - endX; // <--- take note of this for later
float offY = startY - endY;
// atan2 calculates the angle in radians given the height and width of a triangle
// we calculate the delta so that startPoint is effectively at 0, 0
// tl;dr: atan2 converts from cartesian offsets to the angle needed to reach them
float direction = atan2(offY, offX);
CGPoint p1 = CGPointMake(startX, startY);
// here you're converting back from the angle to cartesian coordinates
// cos() calculates the x offset based on direction, sin() does the y
CGPoint p2 = CGPointMake(startX + cos(direction) * 100 * - 1, startY + sin(direction) * 100 * -1);
Cleaning up a little
it's worth noting that you're multiplying by 100
(your scaling factor) but also by -1
which is unnecessary:
Ideally offX and offY should be how far you have to travel to get from start to finish, but you've got that backwards, so:
float deltaX = endX - startX; // the distance from start to end on the horizontal
float deltaY = endY - startY; // in case it's not immediately apparent, I've switched the start and end
// ... SNIP ...
CGPoint p2 = CGPointMake(startX + cos(direction) * 100, startY + sin(direction) * 100);
Get to the point already
but even that is unnecessary - you're converting one way and then back. If you really want just the length, use Pythagoras' Theorem:
float deltaX = endX - startX;
float deltaY = endY - startY;
float distance = sqrt( deltaX*deltaX + deltaY*deltaY );
But I really must say: I still don't follow why you can't just put endX and endY into the CGPointMake function?
// this should work given your code in the comments, unless that `100` is a scaling factor for a weird coordinate system?
CGPoint p2 = CGPointMake(endX, endY);
ooh and another thing:
// if it _is_ a scaling factor, just normalise the point and then multiply by the desired scale:
float deltaX = endX - startX;
float deltaY = endY - startY;
// take away the minus sign and then return the maximum value
float maximum = max( abs(deltaX), abs(deltaY) );
deltaX /= maximum;
deltaY /= maximum;
CGPoint p2 = CGPointMake( startX + (deltaX * 100), startY + (deltaY * 100) );
I highly recommend having a google party for trigonometry tutorials, a lot of the straight math texts can be a little dry and unsatisfying, but have try adding "for programmers" in the query :) (alas I'm not at my usual machine so I can't recommend any right now - I shall return with resources).
(Sorry to put this in an answer; I can't reply in comments yet)