Sample

Schnappinger/aoi/artofillusion.raytracer.RTDirectionalLight

Human rating uses the original dataset scale.

Human3.95
Lines49

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
57.2Δ 5.5
Scalabrino0.5220–1; higher is more readable
11.0Δ 51.7
Dorn0.5670–1; higher is more readable
64.0Δ 1.3
Mi0.7030–1; higher is more readable
83.8Δ 21.1
LLOC14Logical lines; fewer is more readable
66.8Δ 4.1
DeepSeek V4 Pro17.670–20; mean of three runs
83.0Δ 20.3
GPT-6.1 Sol180–20; mean of three runs
73.8Δ 11.1
BTTF0.5510–1; higher is more readable
50.5Δ 12.2
Human3.951–4; original rating
62.7

Views

Source code

/* Copyright (C) 2008-2013 by Peter Eastman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package artofillusion.raytracer; import artofillusion.math.*; import artofillusion.object.*; /** * This subclass of RTLight is used for DirectionalLights. */ public class RTDirectionalLight extends RTLight { private final double radius; public RTDirectionalLight(DirectionalLight light, CoordinateSystem coords, boolean softShadows) { super(light, coords); radius = (softShadows ? Math.tan(light.getRadius()*Math.PI/180.0) : 0.0); } public double findRayToLight(Vec3 origin, Ray ray, RaytracerRenderer renderer, int rayNumber) { ray.getOrigin().set(origin); Vec3 dir = ray.getDirection(); dir.set(getCoords().getZDirection()); dir.scale(-1.0); if (rayNumber != -1) { renderer.randomizePoint(dir, ray.rt.random, radius, rayNumber); dir.normalize(); } return Double.MAX_VALUE; } @Override public boolean getSoftShadows() { return radius != 0.0 && getLight().getType() == Light.TYPE_NORMAL; } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.1237.09−40.824
Source linesThe number of non-empty source lines.49+19.6
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.5.015−7.522

Intercept 8.87 + feature contributions = -19.876 (log-odds).
Score = sigmoid(-19.876) = 0.

Score0.522

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.96.86+0.758
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.50−0.734
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.39−0.474
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.96.94−0.441
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.847+0.273
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.076+0.207

Intercept 0.07 + feature contributions = 0.271 (log-odds).
Score = sigmoid(0.271) = 0.567.

Score0.703
Score14
Run 1

The code is well-structured and demonstrates clear intent. The class has a single, focused responsibility—representing a directional light in a ray tracer. The constructor is concise and initializes the radius with a clear conditional expression. The findRayToLight method is flat, with only one level of nesting, and each action is separated logically: setting the origin, retrieving and adjusting the direction, optionally randomizing, and returning the distance. Variable names are descriptive, and the use of constants like Double.MAX_VALUE and Math.PI is appropriate. However, the soft shadow logic in getSoftShadows is slightly dense, combining a type check with a radius check in one return statement. Overall, the code is readable and maintainable.

Run 2

The code is well-structured and readable. It has a clear class purpose, straightforward constructor logic, and concise method implementations. Nesting is minimal (one conditional inside a method), and intent is easy to discern: compute ray direction for a directional light, optionally jitter for soft shadows. Actions are mostly one per line. The only slight readability cost is the ternary expression for 'radius', which crams two possible outcomes into one line, and the boolean combination in getSoftShadows(), which requires a moment to parse. Overall, naming is clear, the flow is natural, and the length is appropriate for the task.

Run 3

The code is well-structured and highly readable. It has a clear class hierarchy, concise methods, and logical organization. The constructor cleanly handles the soft shadow flag, and findRayToLight is focused with one primary action per line. Nesting is minimal, with only one conditional block. Variable names are descriptive (radius, dir, renderer). The code is concise without sacrificing clarity. The main minor deductions are for the lack of a comment explaining the radius calculation formula and slight ambiguity in getSoftShadows's type check. Overall, it follows good Java practices and reads naturally from top to bottom.

Run 1

Code Structure: The class is logically organized into a field, constructor, and two focused methods. Nesting: A single conditional keeps control flow shallow and easy to follow. Clarity of intent: Class and method names communicate the directional-light purpose, though the meanings of rayNumber == -1, Double.MAX_VALUE, and the radius conversion are not explained. Code length: The implementation is compact without unnecessary repetition; the license header adds length but does not complicate the logic. Action granularity: Statements generally perform one action per line, making ray initialization and adjustment easy to track. Reading flow: Execution proceeds naturally from setting the origin and direction to optional randomization and normalization. Minor readability weaknesses include abbreviated dir, direct access through ray.rt.random, and wildcard imports.

Run 2

Code Structure: A small, focused class cleanly separates initialization, ray setup, and soft-shadow detection. Nesting: Only one shallow conditional keeps control flow simple. Clarity of intent: Descriptive class and method names make the purpose clear, though the rayNumber sentinel (-1), Double.MAX_VALUE return, and radius angle-to-tangent conversion would benefit from brief explanations. Code length: Concise, with no unnecessary implementation code. Action granularity: Statements generally perform one action per line, making mutations easy to follow. Reading flow: Methods proceed naturally from setup to adjustment to return; consistent formatting supports scanning. Wildcard imports and abbreviated names such as dir and coords slightly reduce explicitness.

Run 3

Code Structure: The class is logically organized into a field, constructor, and two focused methods. Nesting: Only one shallow conditional keeps control flow easy to follow. Clarity of intent: Descriptive class and method names establish the purpose, but the rayNumber sentinel -1, Double.MAX_VALUE return, and angular-radius conversion would benefit from brief explanations. Code length: The implementation is concise without unnecessary duplication; the license header does not obscure the small class. Action granularity: Most statements perform one action per line, making ray initialization and direction adjustment easy to track. Reading flow: Operations follow a natural sequence from setup through optional randomization to return. Wildcard imports, the abbreviated variable dir, and limited documentation of numerical conventions are minor readability drawbacks.