Re: [LDPartEditor] Optional Lines
 April 07, 2014 02:58PM LDraw Part Author/Reviewer Registered: 3 years agoPosts: 164
Imagine an optional line with the four points A2, B2, C2 and D2.

1. Take these points and multiply them by their perspective and modelview matrix M.
As a result you'll get A, B, C and D in screen coordinates.

```Matrix4f.transform(M, A2, A);
Matrix4f.transform(M, B2, B);
Matrix4f.transform(M, C2, C);
Matrix4f.transform(M, D2, D);```

2. Calculate the line normal

```N.x = A.y - B.y;
N.y = B.x - A.x;```

3. Calculate the discriminant r by

`r = Vector4f.dot(N, Vector4f.sub(C, A)) * Vector4f.dot(N, Vector4f.sub(D, A));`

where Vector4f.dot() calculates the dot product of these two vectors and Vector4f.sub() the difference vector.

4. draw the line between A2 and B2 only if r > 0
SubjectAuthorViewsPosted
Nils Schmidt1772November 29, 2012 09:30AM
Philippe Hurbain449November 29, 2012 11:06AM
Rolf Osterthun452November 29, 2012 01:34PM
Tim Gould473November 29, 2012 11:58AM
Nils Schmidt408December 25, 2012 03:19AM
Philippe Hurbain445December 25, 2012 06:30AM
Nils Schmidt546December 27, 2012 11:00AM
Nils Schmidt526December 29, 2012 01:39PM
Philippe Hurbain439December 29, 2012 02:17PM
Willy Tschager436January 19, 2013 12:50PM
Michael Heidemann469January 20, 2013 12:32AM
Nils Schmidt466January 08, 2013 03:47PM
Willy Tschager421January 09, 2013 12:03AM
Nils Schmidt463January 09, 2013 04:26AM
Nils Schmidt541January 13, 2013 10:58AM
Willy Tschager473January 13, 2013 01:00PM
Nils Schmidt324March 24, 2014 10:54AM
Nils Schmidt280May 06, 2014 10:36AM
Nils Schmidt391January 18, 2013 07:25AM
Philippe Hurbain440January 18, 2013 10:37AM
Nils Schmidt375January 27, 2013 12:04PM
Nils Schmidt444February 06, 2013 02:18PM
Philippe Hurbain551February 07, 2013 12:01AM
Nils Schmidt382March 09, 2014 08:14AM
Tim Gould297March 09, 2014 02:18PM
Willy Tschager271March 12, 2014 05:21AM
Nils Schmidt229March 24, 2014 10:32AM
Nils Schmidt258March 24, 2014 10:50AM
Nils Schmidt315March 27, 2014 02:58PM
Santeri Piippo274March 27, 2014 03:13PM
Max Martin Richter289March 27, 2014 03:20PM
Nils Schmidt417April 03, 2014 12:04PM
Philippe Hurbain544April 04, 2014 12:12AM
Willy Tschager517April 04, 2014 12:48AM
Michael Heidemann497April 04, 2014 11:57AM
Nils Schmidt641April 04, 2014 02:38PM
Santeri Piippo453April 05, 2014 09:24AM
Nils Schmidt369April 07, 2014 02:58PM
Nils Schmidt513April 05, 2014 08:48AM
Willy Tschager190April 15, 2014 04:31AM
Nils Schmidt290April 15, 2014 09:14AM
Nils Schmidt234April 15, 2014 12:30AM
Nils Schmidt359April 15, 2014 11:33PM
Nils Schmidt381April 17, 2014 03:22PM
Nils Schmidt369April 21, 2014 07:47PM
Philippe Hurbain318April 22, 2014 12:03AM
Michael Heidemann250May 04, 2014 04:17AM
Nils Schmidt266May 10, 2014 03:58PM
Michael Heidemann236May 17, 2014 11:51AM
Nils Schmidt395April 22, 2014 04:05PM
Nils Schmidt258May 04, 2014 03:59AM
Nils Schmidt233May 11, 2014 05:31PM
Stephan Meisinger264May 18, 2014 01:42AM
Nils Schmidt211May 20, 2014 05:12PM
Nils Schmidt246May 20, 2014 04:50PM
Nils Schmidt194July 11, 2014 10:56AM
Nils Schmidt184July 23, 2014 02:06PM
Philippe Hurbain191July 24, 2014 01:07AM
Nils Schmidt320June 02, 2014 02:39AM
Philippe Hurbain237June 02, 2014 04:49AM
Magnus Forsberg272June 02, 2014 09:24AM
Nils Schmidt241June 25, 2014 08:07AM
Nils Schmidt191June 28, 2014 11:28AM
Nils Schmidt183July 15, 2014 11:22AM
Nils Schmidt246July 26, 2014 07:36PM
Nils Schmidt221July 27, 2014 08:48AM
Roland Melkert215July 27, 2014 12:30PM
Travis Cobbs188July 27, 2014 10:40PM
Nils Schmidt208July 28, 2014 05:48AM
Roland Melkert133July 28, 2014 12:50PM
Travis Cobbs171July 28, 2014 04:18PM
Nils Schmidt205July 28, 2014 09:26PM
Roland Melkert179July 29, 2014 11:05AM
Travis Cobbs161July 29, 2014 12:14PM
Roland Melkert179July 29, 2014 12:44PM
Nils Schmidt187July 30, 2014 09:11AM
Tim Gould195July 30, 2014 12:10PM
Nils Schmidt176August 01, 2014 03:38AM
Roland Melkert192August 01, 2014 08:47AM
Ben Supnik221July 30, 2014 05:51PM
Nils Schmidt200July 31, 2014 11:13AM
Roland Melkert158July 31, 2014 12:08PM
Philippe Hurbain171July 31, 2014 01:33PM
Roland Melkert197July 31, 2014 03:18PM
Philippe Hurbain159July 31, 2014 10:42PM
Ben Supnik152July 31, 2014 07:48PM
Roland Melkert175August 01, 2014 08:56AM
Nils Schmidt219July 31, 2014 04:44PM
Roland Melkert178August 01, 2014 08:57AM
Nils Schmidt137August 15, 2014 02:19PM
Nils Schmidt198August 18, 2014 02:44PM
Willy Tschager218August 19, 2014 01:27PM
Nils Schmidt152September 05, 2014 01:01PM
Willy Tschager151September 06, 2014 02:59AM
Nils Schmidt130September 06, 2014 04:08AM
Magnus Forsberg133September 06, 2014 05:48AM
Nils Schmidt216August 26, 2014 09:24PM
Nils Schmidt200September 04, 2014 12:54PM
Nils Schmidt188September 06, 2014 01:58PM
Nils Schmidt178September 16, 2014 07:20AM
Philippe Hurbain147September 16, 2014 08:39AM
Max Martin Richter147September 16, 2014 09:18AM
Nils Schmidt222September 18, 2014 12:33PM
Michael Heidemann217September 19, 2014 07:35AM
Nils Schmidt190September 19, 2014 05:58PM
Philippe Hurbain158September 20, 2014 12:44AM
Michael Heidemann270September 20, 2014 05:27AM

Sorry, only registered users may post in this forum.