NIRT(1)
okay bestie, this is NIRT(1) from BRL-CAD β the manual page for nirt, aka Natalie's Interactive Ray-Tracer π β¨
πΈ NAME πΈ
nirt β interactively ray trace a BRL-CAD geometric model π«Ά
β¨ SYNOPSIS β¨
nirt [options] model.g [objects]...
π DESCRIPTION π
okay so nirt β Natalie's Interactive Ray-Tracer β traces rays through the specified objects in the database model.g, using librt(3), and produces an ASCII report of what each ray encounters. Commands are read from standard input. By default the user interacts with nirt, repeatedly specifying ray origination points and directions and controlling the format and destination of the reports. Locations may be input and output in either model coordinates (x, y, z) or view (a.k.a. grid-plane) coordinates (h, v, d), and direction may be expressed either as a vector in model coordinates or as azimuth and elevation angles. no cap, that's the whole vibe π«
When standard input is not a terminal (for example, when it is redirected from a file or a pipe), nirt defaults to silent mode, making it convenient for scripted ray queries. literally so handy for scripts π§
π OPTIONS π
-h,βhelp,-?β Print a usage message and exit. standard helpful icon behavior π-A nameβ Addnameto the list of object attributes reported by theattributesoutput item. May be repeated to request multiple attributes. See also theattrcommand below. stack those names, bestie π-Mβ Read an eye point and either an orientation quaternion or a view-rotation matrix from standard input, then fire a single ray. This allowsnirtto be driven directly frommged(1)via itsnirtandrrtcommands. direct-drive mode fr fr π₯-bβ Back the ray out of the geometry before the first shot. Deprecated; this is now the default behavior and the flag is a no-op. it's giving retired icon π-cβ Shoot the ray from the current center point rather than backing out of the geometry first.-e scriptβ Run the script string before reading standard input. Multiple commands may be separated with a semicolon.-eand-fscripts run in command-line order.-f formatβ Load the predefined format (see-L) or script file namedformatbefore reading standard input.-eand-fscripts run in command-line order.-Eβ Ignore any-eor-foptions given earlier on the command line. not me ignoring the earlier flags π-Lβ List the available output formats and exit.-sβ Run in silent (non-verbose) mode, suppressing the banner and prompt. Useful in pipelines. quiet queen behavior π€«-vβ Run in verbose mode. Verbose is the default on a terminal; silent is the default when standard input is redirected.-H nβ Enable (n=1, the default) or disable (n=0) the informational header. The header is always off in silent mode.-u nβ Set theuse_airvalue ton, controlling whether air regions are reported. Default is0(air ignored).-O actionβ Control how overlapping regions' claims to a ray segment are handled.actionmay be0or"resolve",1or"rebuild_fastgen",2or"rebuild_all", or3or"retain". See theoverlap_claimscommand below. Default is"resolve".-x vβ Set thelibrt(3)diagnostic (debug) flags to the hexadecimal bit vectorv.-X vβ Setnirt's own diagnostic (debug) flags to the hexadecimal bit vectorv.βcenter x,y,zβ Set the ray origination (center) point to the given model-space coordinates.βxyz x,y,zβ Synonym forβcenter.βplotfile filenameβ Write graphical plot output of the ray segments tofilename.βcolor_odd r/g/bβ Color used when plotting odd-numbered segments (default0/255/255).βcolor_even r/g/bβ Color used when plotting even-numbered segments (default255/255/0).βcolor_gap r/g/bβ Color used when plotting gaps between segments (default255/0/255).βcolor_ovlp r/g/bβ Color used when plotting overlap segments (default255/255/255).-Bβ Deprecated and no longer used; accepted but ignored. it's just there vibing π
nirt also checks for a .nirtrc start-up file, first in the current directory and then in the user's home directory. If found, it is read before interaction begins and may contain any nirt commands, which is useful for loading predefined states or output formats. cute little startup ritual π
π COMMANDS π
center [ x y z ],xyz [ x y z ]β Sets the ray origination point to(x, y, z). If this command is invoked with no arguments,nirtprints the current ray origination point in model coordinates. Default is(0, 0, 0). Changing(x, y, z)will change(h, v, d), according to the current direction vector.hv [ h v [ d ] ]β Sets the ray origination point to(h, v, d). If this command is invoked with only two arguments,nirtinterprets them ashandv, anddretains its previous value. If invoked with no argument, the command causesnirtto print the current ray origination point in view coordinates. Default is(0, 0, 0). Changing(h, v, d)will change(x, y, z), according to the current direction vector.dir [ dx dy dz ]β Sets the direction vector to the unit vector in direction(dx, dy, dz). If this command is invoked with no arguments,nirtprints the current direction vector. Default is(-1, 0, 0). Changing(dx, dy, dz)will change the azimuth and elevation angles.ae [ az el ]β Sets the direction vector to point from azimuth =azand elevation =el. If this command is invoked with no arguments,nirtprints the current values of the azimuth and elevation angles. Default is(0, 0). Changing azimuth and elevation will change the direction vector.sβ Fires a ray from the current origination point in the current direction. go off, ray π₯backout [ n ]β Command to set the backout flag. With no option, prints the current value. When activated, backs the ray origination point out of the geometry:handvretain their previous values anddis set toDmax, the largest value ofdanywhere in the geometry. Default is0(deactivated),1is active.useair [ n ]β Sets theuseairmember of thert_istructure to the integern. Ifnis0, thennirtignores any air in the geometry. If this command is invoked with no arguments,nirtprints the current value ofuseair. Default is0.overlap_claims [ n ]β Specifies how to handle multiple regions' claims to segments of a ray.- If
nis0or"resolve", then all overlaps are resolved in favor of a single region and any other claimants are ignored. - If
nis2or"rebuild_all", then all overlaps are rebuilt, so any overlapping regions along the ray create individual (geometrically intersecting) partitions. - If
nis3or"retain", then all overlaps are retained. In this case, the resulting partitions are always geometrically disjoint, each one is owned by a single region according to the current overlap resolution strategy, but every claimant is recorded. - If
nis1or"rebuild_fastgen", thennirttakes on FASTGEN behavior, so overlaps of plate-mode primitives are rebuilt, but other overlaps are retained. - This command is useful with the
claimant_count,claimant_list, andclaimant_listnoutput items. - Default is
"resolve". overlap drama, handled π
- If
attr {-f|-p|attr_names...}β When used with one or more names, adds the names to the list of attributes that will be printed when the"attributes"value is requested in the output format string.- The
-poption to theattrcommand causes it to print the list of attributes that will be reported. - The
-foption clears the attributes table.
- The
units [ u ]β Causesnirtto read and write all distances and locations in units ofu. Valid choices foruare"mm";"cm";"m";"in"; and"ft". If this command is invoked with no arguments,nirtprints the current choice of I/O units. Default is the units ofmodel.g.fmt [ t format item item ... ]β Sets the action for output statements of typet. If this command is invoked with only one argument, a valid statement type,nirtprints the current format and items for the specified type. See the discussion of output statements below.dest [ d ]β Sets the destination for subsequent output actions tod. If the first character ofdis|, thendis interpreted as a pipeline to which to write its output. Otherwise, ifdis the string"default",nirtsets the destination to the standard output. Otherwise,dis interpreted as a file. In any event,dis not closed until the user quitsnirtor resets the destination by another invocation of thedestcommand. If this command is invoked with no arguments,nirtprints the current value ofd. Default is"default", that is, the standard output.statefile [ f ]β Sets the name of the state file to which to dump and from which to load state information. See the discussion of thedumpandloadcommands below. If this command is invoked with no arguments,nirtprints the current name of the state file. Default is"nirt_state".dumpβ Writes state information to the state file. The ray origination point and direction vector,useair, units, destination, and all the output actions are dumped. save the lore β¨loadβ Reads state information from the state file. The state file loaded may contain anynirtcommands.clearβ Clears text from the terminal screen (interactive mode only).print itemβ Prints the current value of the output itemitem. See the discussion of output statements below.libdebug vβ Sets thelibrt(3)debug flags (thedebugmember of thert_gstructure) to the hexadecimal bit vectorv. These flags control the amount and kind of diagnostic print statementslibrt(3)executes. Ifvis0, then no diagnostics are produced. If this command is invoked with no arguments,nirtprints the current value ofvand the names of any of its bits that are set. Default is0.debug vβ Setsnirt's internal debug flags to the hexadecimal bit vectorv. These flags control the amount and kind of diagnostic print statementsnirtexecutes. Ifvis0, then no diagnostics are produced. If this command is invoked with no arguments,nirtprints the current value ofvand the names of any of its bits that are set. Default is0.?β Prints a help menu to the standard output.qβ Quitsnirt.
π OUTPUT STATEMENTS π
okay so nirt gives you a high degree of control, via the fmt command, over what information gets printed out for each ray and in what format. There are six types of output statements, each of which is executed under appropriate circumstances. The types and their use are β and yes, the list below has seven bullets, we are keeping every single one, do not come for me π:
rβ Ray. The first output statement executed whenever thescommand is invoked.hβ Head. Executed immediately after the ray statement if the ray hits anything.pβ Partition. Executed once for each partition along the ray if the ray hits anything.fβ Foot. The last output statement executed if the ray hits anything.mβ Miss. Executed immediately after the ray statement if the ray hits nothing.oβ Overlap. Executed once for each overlap along the ray if the ray hits anything.gβ Gap. Executed once for each gap along the ray if the ray encounters any gaps.
The action associated with each output statement type is essentially a printf(3) statement, with a format string and a list of output items. The items may be chosen from a set of values that nirt updates according to user commands and location along the ray. These values may be categorized as pertaining to the entire ray, partitions along the ray, or overlaps. The values are explained in the following table.
β¨ Ray Information β¨
x_origβ x coordinate of ray origination point.y_origβ y coordinate of ray origination point.z_origβ z coordinate of ray origination point.d_origβ d coordinate of ray origination point.hβ h coordinate for the entire ray.vβ v coordinate for the entire ray.x_dirβ x component of direction vector.y_dirβ y component of direction vector.z_dirβ z component of direction vector.aβ azimuth of view (i.e., of ray direction).eβ elevation of view (i.e., of ray direction).
πΈ Partition Information πΈ
attributesβ A string variable consisting of the names and values of the attributes requested by theattrcommand or the-Acommand line option.x_inβ x coordinate of entry into current region.y_inβ y coordinate of entry into current region.z_inβ z coordinate of entry into current region.d_inβ d coordinate of entry into current region.x_outβ x coordinate of exit from current region.y_outβ y coordinate of exit from current region.z_outβ z coordinate of exit from current region.d_outβ d coordinate of exit from current region.losβ line-of-sight distance through current region.scaled_losβ scaled line of sight: product of line-of-sight distance through current region and region solidity (sometimes called "percent LOS").path_nameβ full path name of current region.reg_nameβ name of current region, as might be obtained by passingpath_nametobasename(1).reg_idβ region ID of current region.claimant_countβ number of regions claiming this partition (that is, participating in a retained overlap).claimant_listβ space-separated list of names of regions claiming this partition (that is, participating in a retained overlap).claimant_listnβ Same asclaimant_list, except that it is newline-, rather than space-separated.obliq_inβ entry obliquity for current region.obliq_outβ exit obliquity for current region.nm_x_inβ x component of entry normal vectornm_y_inβ y component of entry normal vectornm_z_inβ z component of entry normal vectornm_h_inβ h component of entry normal vectornm_v_inβ v component of entry normal vectornm_d_inβ d component of entry normal vectornm_x_outβ x component of exit normal vectornm_y_outβ y component of exit normal vectornm_z_outβ z component of exit normal vectornm_h_outβ h component of exit normal vectornm_v_outβ v component of exit normal vectornm_d_outβ d component of exit normal vectorsurf_num_inβ entry-surface ID of entry solid.surf_num_outβ exit-surface ID of exit solid.
π¦ Gap Information π¦
x_gap_inβ x coordinate of entry into gap.y_gap_inβ y coordinate of entry into gap.z_gap_inβ z coordinate of entry into gap.gap_losβ line-of-sight distance through gap.
π Overlap Information π
ov_reg1_nameβ name of one of the overlapping regions.ov_reg2_nameβ name of the other overlapping region.ov_reg1_idβ region ID of one of the overlapping regions.ov_reg2_idβ region ID of the other overlapping region.ov_sol_inβ name of one of the overlapping solids.ov_sol_outβ name of the other overlapping solid.ov_losβ line-of-sight distance through the overlap.ov_x_inβ x coordinate of entry into overlap.ov_y_inβ y coordinate of entry into overlap.ov_z_inβ z coordinate of entry into overlap.ov_d_inβ d coordinate of entry into overlap.ov_x_outβ x coordinate of exit from overlap.ov_y_outβ y coordinate of exit from overlap.ov_z_outβ z coordinate of exit from overlap.ov_d_outβ d coordinate of exit from overlap.
π EXAMPLES π
Example 1. Scripted line-of-sight query through a model
printf 'xyz 0 0 0\ndir 1 0 0\ns\n' | nirt -s model.g component
Because standard input is a pipe, nirt runs silently. The script positions the ray origin, aims it down the +X axis, and fires a single shot, printing only the ray report for the component object. This is a convenient way to measure line-of-sight distances or material thickness from a shell script.
Example 2. Reporting custom attributes for each region hit
nirt -A material_id -A los_density model.g all
Each region the ray passes through is reported together with its material_id and los_density attribute values via the attributes output item, which is useful for vulnerability and mass-properties analyses.
π HINTS π
Ray origination coordinates specified with the hv command are immediately converted for internal use to model coordinates, according to the current direction vector. If you want to change the ray direction and origination point, and you're using view coordinates, you probably want to change the ray direction before you use the hv command.
The name nirt stands for "Natalie's interactive ray tracer".
π§ DEFINITIONS π§
The usage in nirt of the following terms corresponds to that found in mged(1) and elsewhere throughout BRL-CAD. We provide the definitions here for reference.
View Coordinates
We define the view coordinate system (more precisely its basis vectors m, n, and o) in terms of the basis vectors i, j, and k of the model coordinate system as follows:
m is the opposite of the direction vector and corresponds to d, n = k Γ m corresponds to h, and o = m Γ n corresponds to v.
Thus if the direction vector is (-1, 0, 0), then (d, h, v) = (x, y, z).
Azimuth and Elevation
Azimuth is the angle measured around k (right-hand rule) from the xz plane to m. Elevation is the angle measured toward k from the xy plane to m.
π FILES π
./.nirtrc,~/.nirtrcβ run-time configuration file, searched first in the current directory and then in the home directory
π₯ SEE ALSO π₯
brlcad(1), mged(1), rt(1), librt(3), printf(3)
π AUTHOR π
BRL-CAD Team
β COPYRIGHT β
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.
π¦ BUG REPORTS π¦
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org
xoxo, BRL-CAD β NIRT(1), Β© 1989β2026, catch you in the terminal π
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms