tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* \w'blah'u issues (really: 'u' scaling width)
@ 2014-08-09 17:01 Kristaps Dzonsons
  2014-08-09 20:41 ` Ingo Schwarze
  0 siblings, 1 reply; 4+ messages in thread
From: Kristaps Dzonsons @ 2014-08-09 17:01 UTC (permalink / raw)
  To: tech

[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]

Hello,

Earlier I mentioned, as an aside, that OpenGL manuals look bad.  Try 
rendering gluPerspective to see what I mean.  (Attached.)

I tracked this down to the following:

.SH PARAMETERS
.TP \w'\fIaspect\fP\ \ 'u
\f2fovy\fP
Specifies the field of view angle, in degrees, in the \f2y\fP direction.
.TP
\f2aspect\fP

Note that the width of the TP head is being set to the contents of 
\w'xxx'.  So this should be interpreted as

.Tp <width of "aspect  ">u

which should amount to 8 character widths.

However, in roff.c:630, we multiply this width by 24.  As a result, 
everything's wonky.  (8 * 24 = a long line)

At first I thought that we should just yank the 24.  But in running a 
little test, it seems that the \w'' doesn't calculate the string width 
in characters, but in magic internal units.  So it's not that we 
shouldn't multiply by 24, but instead that the "u" scaling unit should 
*divide* by 24.

The test was:

.TH FOO 1
.TP \w'h'u
hello
world
.TP 24u
hello
world
.TP 48u
hello
world

These now display similarly between mandoc and nroff with the enclosed 
patch, though I haven't tested it exhaustively.  Thoughts?

Best,

Kristaps

[-- Attachment #2: gluPerspective.3 --]
[-- Type: text/plain, Size: 2653 bytes --]

'\" e  
'\"macro stdmacro
.ds Vn Version 1.2
.ds Dt 6 March 1997
.ds Re Release 1.2.0
.ds Dp May 22 14:54
.ds Dm 0 May 22 14:
.ds Xs 14699     5
.TH GLUPERSPECTIVE 3G
.SH NAME
.B "gluPerspective
\- set up a perspective projection matrix

.SH C SPECIFICATION
void \f3gluPerspective\fP(
GLdouble \fIfovy\fP,
.nf
.ta \w'\f3void \fPgluPerspective( 'u
	GLdouble \fIaspect\fP,
	GLdouble \fIzNear\fP,
	GLdouble \fIzFar\fP )
.fi

.SH PARAMETERS
.TP \w'\fIaspect\fP\ \ 'u 
\f2fovy\fP
Specifies the field of view angle, in degrees, in the \f2y\fP direction.
.TP
\f2aspect\fP
Specifies the aspect ratio that determines
the field of view in the \f2x\fP direction.
The aspect ratio is the ratio of \f2x\fP (width) to \f2y\fP (height).
.TP
\f2zNear\fP
Specifies the distance from the viewer to the near clipping plane
(always positive).
.TP
\f2zFar\fP
Specifies the distance from the viewer to the far clipping plane
(always positive).
.SH DESCRIPTION
\%\f3gluPerspective\fP specifies a viewing frustum into the world coordinate system.
In general, the aspect ratio in \%\f3gluPerspective\fP should match the aspect ratio
of the associated viewport. For example, aspect = 2.0 means 
the viewer's
angle of view is twice as wide in \f2x\fP as it is in \f2y\fP.
If the viewport is
twice as wide as it is tall, it displays the image without distortion.
.P
The matrix generated by \%\f3gluPerspective\fP is multipled by the current matrix,
just as if \f3glMultMatrix\fP were called with the generated matrix.
To load the perspective matrix onto the current matrix stack instead,
precede the call to \%\f3gluPerspective\fP with a call to \f3glLoadIdentity\fP.
.P
Given \f2f\fP defined as follows:
.sp
.ce
f  = cotangent(fovy/2)

The generated matrix is
.Bd -literal
      f
 ------------       0              0              0
    aspect

                 
     0              f              0              0

                               zFar+zNear    2*zFar*zNear
     0              0          ----------    ------------
                               zNear-zFar     zNear-zFar

     0              0              -1             0

.Ed

.SH NOTES
Depth buffer precision is affected by the values specified for
\f2zNear\fP and \f2zFar\fP.
The greater the ratio of \f2zFar\fP to \f2zNear\fP is,
the less effective the depth buffer will be at distinguishing between
surfaces that are near each other.
If 

.ce
r = zFar/zNear

.P
roughly log2(r) bits of depth buffer precision are lost.
Because r approaches infinity as \f2zNear\fP approaches 0,
\f2zNear\fP must never be set to 0.
.SH SEE ALSO
\f3glFrustum\fP, \f3glLoadIdentity\fP,
\f3glMultMatrix\fP, \%\f3gluOrtho2D\fP

[-- Attachment #3: scale.diff --]
[-- Type: text/plain, Size: 2010 bytes --]

Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.62
diff -u -p -r1.62 term_ps.c
--- term_ps.c	1 Aug 2014 19:25:52 -0000	1.62
+++ term_ps.c	9 Aug 2014 16:59:03 -0000
@@ -1145,6 +1145,9 @@ ps_hspan(const struct termp *p, const st
 	case SCALE_VS:
 		r = su->scale * p->ps->lineheight;
 		break;
+	case SCALE_BU:
+		r = PNT2AFM(p, su->scale / 3.0);
+		break;
 	default:
 		r = su->scale;
 		break;
Index: term_ascii.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v
retrieving revision 1.27
diff -u -p -r1.27 term_ascii.c
--- term_ascii.c	1 Aug 2014 19:25:52 -0000	1.27
+++ term_ascii.c	9 Aug 2014 16:59:04 -0000
@@ -255,6 +255,9 @@ ascii_hspan(const struct termp *p, const
 	case SCALE_VS:
 		r = su->scale * 2.0 - 1.0;
 		break;
+	case SCALE_BU:
+		r = su->scale / 24.0;
+		break;
 	default:
 		r = su->scale;
 		break;
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.226
diff -u -p -r1.226 term.c
--- term.c	1 Aug 2014 19:38:29 -0000	1.226
+++ term.c	9 Aug 2014 16:59:04 -0000
@@ -786,6 +786,9 @@ term_vspan(const struct termp *p, const 
 	case SCALE_VS:
 		r = su->scale;
 		break;
+	case SCALE_BU:
+		r = su->scale / 24.0;
+		break;
 	default:
 		r = su->scale - 1.0;
 		break;
Index: html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v
retrieving revision 1.159
diff -u -p -r1.159 html.c
--- html.c	23 Jul 2014 15:00:08 -0000	1.159
+++ html.c	9 Aug 2014 16:59:04 -0000
@@ -761,6 +761,8 @@ bufcat_su(struct html *h, const char *p,
 	v = su->scale;
 	if (SCALE_MM == su->unit && 0.0 == (v /= 100.0))
 		v = 1.0;
+	if (SCALE_BU == su->unit)
+		v /= 24.0;
 
 	bufcat_fmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]);
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-12  2:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09 17:01 \w'blah'u issues (really: 'u' scaling width) Kristaps Dzonsons
2014-08-09 20:41 ` Ingo Schwarze
2014-08-12  1:04   ` Kristaps Dzonsons
2014-08-12  2:43     ` Ingo Schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).