Skip to content

Problem when rotating to horizontal #39

@rmcdouga

Description

@rmcdouga

I'm seeing an issue when I run the following test:

	@Test
	void testSvgProblem() throws Exception {
		SVGGraphics2D g2 = new SVGGraphics2D(4986, 3216);

		int marker_size = 65;
		int local_diameter = 600;
		int radius = local_diameter/2;
		double arc_size = Math.PI / 12;
		
		g2.translate(1000, 500);
		
		g2.setColor(Color.BLUE);
		g2.setStroke(new BasicStroke(2));
		g2.drawOval(-radius, -radius, local_diameter, local_diameter);
		
		// draw sector lines
		g2.drawLine(0, -radius - marker_size / 2, 0, -radius + marker_size / 2);

		g2.rotate(arc_size*2);	// rotate past the orbit arc
		
		// draw sector lines
		int halfMarkerSize = marker_size / 2;
		g2.drawLine(0, -radius - halfMarkerSize, 0, -radius + halfMarkerSize);
		
		for (int i = 0; i < 6; i++) {
			g2.rotate(arc_size);
			g2.drawLine(0, -radius - halfMarkerSize, 0, -radius + halfMarkerSize);
			g2.drawString(Integer.toString(i), 0, -radius);
		}
	
		String result = g2.getSVGDocument();
		Files.writeString(TestConstants.ACTUAL_RESULTS_DIR.resolve("TestSvgProblem.svg"), result);
	}

It creates a circle and then creates a series of lines that are perpendicular to the circle. When the line is horizontal (as in line 3), the transformation matrix looks like it is incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions