<commit_before><commit_msg>Adding RenderUtil -- a collection of static utility methods for rendering.<commit_after>/**
 * 
 */
package ca.eandb.jmist.framework;

import ca.eandb.jmist.math.Basis3;
import ca.eandb.jmist.math.Point2;
import ca.eandb.jmist.math.Point3;
import ca.eandb.jmist.math.Vector3;

/**
 * @author brad
 *
 */
public final class RenderUtil {
	
	/**
	 * This constructor is private because this class cannot be instantiated.
	 */
	private RenderUtil() {}
	
	private static final class SimpleSurfacePointGeometry implements SurfacePointGeometry {
		
		private final Point3 position;
		private final Basis3 basis;
		private final Basis3 shadingBasis;
		private final Point2 textureCoordinates;
		
		/**
		 * @param position
		 * @param basis
		 * @param shadingBasis
		 * @param textureCoordinates
		 */
		public SimpleSurfacePointGeometry(Point3 position, Basis3 basis,
				Basis3 shadingBasis, Point2 textureCoordinates) {
			this.position = position;
			this.basis = basis;
			this.shadingBasis = shadingBasis;
			this.textureCoordinates = textureCoordinates;
		}

		public Basis3 getBasis() {
			return basis;
		}

		public Vector3 getNormal() {
			return basis.w();
		}

		public Point3 getPosition() {
			return position;
		}

		public int getPrimitiveIndex() {
			return 0;
		}

		public Basis3 getShadingBasis() {
			return null;
		}

		public Vector3 getShadingNormal() {
			return shadingBasis.w();
		}

		public Vector3 getTangent() {
			return basis.u();
		}

		public Point2 getUV() {
			return textureCoordinates;
		}
		
	}
	
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Vector3 N) {
		Basis3 basis = Basis3.fromW(N);
		return new SimpleSurfacePointGeometry(p, basis, basis, Point2.ORIGIN);
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Vector3 N, Vector3 shadingNormal) {
		Basis3 basis = Basis3.fromW(N);
		Basis3 shadingBasis = Basis3.fromW(shadingNormal);
		return new SimpleSurfacePointGeometry(p, basis, shadingBasis, Point2.ORIGIN);
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Basis3 basis) {
		return new SimpleSurfacePointGeometry(p, basis, basis, Point2.ORIGIN);
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Basis3 basis, Basis3 shadingBasis) {
		return new SimpleSurfacePointGeometry(p, basis, shadingBasis, Point2.ORIGIN);
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Vector3 N, Point2 uv) {
		Basis3 basis = Basis3.fromW(N);
		return new SimpleSurfacePointGeometry(p, basis, basis, uv);		
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Vector3 N, Vector3 shadingNormal, Point2 uv) {
		Basis3 basis = Basis3.fromW(N);
		Basis3 shadingBasis = Basis3.fromW(shadingNormal);
		return new SimpleSurfacePointGeometry(p, basis, shadingBasis, uv);
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Basis3 basis, Point2 uv) {
		return new SimpleSurfacePointGeometry(p, basis, basis, uv);
	}
	
	public static SurfacePointGeometry createSurfacePointGeometry(Point3 p, Basis3 basis, Basis3 shadingBasis, Point2 uv) {
		return new SimpleSurfacePointGeometry(p, basis, shadingBasis, uv);
	}

}
{'fraction_non_alphanumeric': 0.08538840937114674, 'fraction_numerical': 0.018495684340320593, 'mean_word_length': 4.594827586206897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5386083', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1003, 'n_words': 265}