{ "cells": [ { "cell_type": "markdown", "id": "aaadd680", "metadata": {}, "source": [ "# basic3d\n", "\n", "\n", "\n", "\n", "**Author:** Rene Brun \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:36 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "3ec2bc3b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:48.885562Z", "iopub.status.busy": "2026-05-19T20:36:48.885440Z", "iopub.status.idle": "2026-05-19T20:36:49.258659Z", "shell.execute_reply": "2026-05-19T20:36:49.244678Z" } }, "outputs": [], "source": [ "TCanvas *c1 = new TCanvas(\"c1\", \"PolyLine3D & PolyMarker3D Window\", 200, 10, 700, 500);" ] }, { "cell_type": "markdown", "id": "877c195b", "metadata": {}, "source": [ "create a pad" ] }, { "cell_type": "code", "execution_count": 2, "id": "b0bbe77e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:49.265193Z", "iopub.status.busy": "2026-05-19T20:36:49.265003Z", "iopub.status.idle": "2026-05-19T20:36:49.474571Z", "shell.execute_reply": "2026-05-19T20:36:49.474036Z" } }, "outputs": [], "source": [ "TPad *p1 = new TPad(\"p1\", \"p1\", 0.05, 0.02, 0.95, 0.82, 46, 3, 1);\n", "p1->Draw();\n", "p1->cd();" ] }, { "cell_type": "markdown", "id": "cdf0c2f0", "metadata": {}, "source": [ "creating a view" ] }, { "cell_type": "code", "execution_count": 3, "id": "eb2348e0", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:49.476399Z", "iopub.status.busy": "2026-05-19T20:36:49.476257Z", "iopub.status.idle": "2026-05-19T20:36:49.686065Z", "shell.execute_reply": "2026-05-19T20:36:49.685347Z" } }, "outputs": [], "source": [ "TView *view = TView::CreateView(1);\n", "view->SetRange(5, 5, 5, 25, 25, 25);" ] }, { "cell_type": "markdown", "id": "d356cd23", "metadata": {}, "source": [ "create a first PolyLine3D" ] }, { "cell_type": "code", "execution_count": 4, "id": "ff99d222", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:49.687887Z", "iopub.status.busy": "2026-05-19T20:36:49.687767Z", "iopub.status.idle": "2026-05-19T20:36:49.897439Z", "shell.execute_reply": "2026-05-19T20:36:49.896900Z" } }, "outputs": [], "source": [ "TPolyLine3D *pl3d1 = new TPolyLine3D(5);" ] }, { "cell_type": "markdown", "id": "d0cce950", "metadata": {}, "source": [ "set points" ] }, { "cell_type": "code", "execution_count": 5, "id": "8ba278ef", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:49.914432Z", "iopub.status.busy": "2026-05-19T20:36:49.914285Z", "iopub.status.idle": "2026-05-19T20:36:50.124004Z", "shell.execute_reply": "2026-05-19T20:36:50.123618Z" } }, "outputs": [], "source": [ "pl3d1->SetPoint(0, 10, 10, 10);\n", "pl3d1->SetPoint(1, 15, 15, 10);\n", "pl3d1->SetPoint(2, 20, 15, 15);\n", "pl3d1->SetPoint(3, 20, 20, 20);\n", "pl3d1->SetPoint(4, 10, 10, 20);" ] }, { "cell_type": "markdown", "id": "ddbfa3b4", "metadata": {}, "source": [ "set attributes" ] }, { "cell_type": "code", "execution_count": 6, "id": "ee2697ee", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:50.134044Z", "iopub.status.busy": "2026-05-19T20:36:50.133916Z", "iopub.status.idle": "2026-05-19T20:36:50.371288Z", "shell.execute_reply": "2026-05-19T20:36:50.354413Z" } }, "outputs": [], "source": [ "pl3d1->SetLineWidth(3);\n", "pl3d1->SetLineColor(5);" ] }, { "cell_type": "markdown", "id": "8f6633f9", "metadata": {}, "source": [ "create a second PolyLine3D" ] }, { "cell_type": "code", "execution_count": 7, "id": "6400beb5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:50.373324Z", "iopub.status.busy": "2026-05-19T20:36:50.373192Z", "iopub.status.idle": "2026-05-19T20:36:50.594350Z", "shell.execute_reply": "2026-05-19T20:36:50.593251Z" } }, "outputs": [], "source": [ "TPolyLine3D *pl3d2 = new TPolyLine3D(4);" ] }, { "cell_type": "markdown", "id": "4942e173", "metadata": {}, "source": [ "set points" ] }, { "cell_type": "code", "execution_count": 8, "id": "e543c900", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:50.595838Z", "iopub.status.busy": "2026-05-19T20:36:50.595707Z", "iopub.status.idle": "2026-05-19T20:36:50.805699Z", "shell.execute_reply": "2026-05-19T20:36:50.804596Z" } }, "outputs": [], "source": [ "pl3d2->SetPoint(0, 5, 10, 5);\n", "pl3d2->SetPoint(1, 10, 15, 8);\n", "pl3d2->SetPoint(2, 15, 15, 18);\n", "pl3d2->SetPoint(3, 5, 20, 20);\n", "pl3d2->SetPoint(4, 10, 10, 5);" ] }, { "cell_type": "markdown", "id": "4c153440", "metadata": {}, "source": [ "set attributes" ] }, { "cell_type": "code", "execution_count": 9, "id": "58e01e5e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:50.807201Z", "iopub.status.busy": "2026-05-19T20:36:50.807074Z", "iopub.status.idle": "2026-05-19T20:36:51.022683Z", "shell.execute_reply": "2026-05-19T20:36:51.021599Z" } }, "outputs": [], "source": [ "pl3d2->SetLineWidth(5);\n", "pl3d2->SetLineColor(2);" ] }, { "cell_type": "markdown", "id": "c761004e", "metadata": {}, "source": [ "create a first PolyMarker3D" ] }, { "cell_type": "code", "execution_count": 10, "id": "837ef22e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:51.024165Z", "iopub.status.busy": "2026-05-19T20:36:51.024043Z", "iopub.status.idle": "2026-05-19T20:36:51.241573Z", "shell.execute_reply": "2026-05-19T20:36:51.240468Z" } }, "outputs": [], "source": [ "TPolyMarker3D *pm3d1 = new TPolyMarker3D(12);" ] }, { "cell_type": "markdown", "id": "1cc0d771", "metadata": {}, "source": [ "set points" ] }, { "cell_type": "code", "execution_count": 11, "id": "bba4cd40", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:51.243092Z", "iopub.status.busy": "2026-05-19T20:36:51.242965Z", "iopub.status.idle": "2026-05-19T20:36:51.475019Z", "shell.execute_reply": "2026-05-19T20:36:51.468058Z" } }, "outputs": [], "source": [ "pm3d1->SetPoint(0, 10, 10, 10);\n", "pm3d1->SetPoint(1, 11, 15, 11);\n", "pm3d1->SetPoint(2, 12, 15, 9);\n", "pm3d1->SetPoint(3, 13, 17, 20);\n", "pm3d1->SetPoint(4, 14, 16, 15);\n", "pm3d1->SetPoint(5, 15, 20, 15);\n", "pm3d1->SetPoint(6, 16, 18, 10);\n", "pm3d1->SetPoint(7, 17, 15, 10);\n", "pm3d1->SetPoint(8, 18, 22, 15);\n", "pm3d1->SetPoint(9, 19, 28, 25);\n", "pm3d1->SetPoint(10, 20, 12, 15);\n", "pm3d1->SetPoint(11, 21, 12, 15);" ] }, { "cell_type": "markdown", "id": "95cbb916", "metadata": {}, "source": [ "set marker size, color & style" ] }, { "cell_type": "code", "execution_count": 12, "id": "0b52cdf9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:51.494336Z", "iopub.status.busy": "2026-05-19T20:36:51.494174Z", "iopub.status.idle": "2026-05-19T20:36:51.721410Z", "shell.execute_reply": "2026-05-19T20:36:51.708405Z" } }, "outputs": [], "source": [ "pm3d1->SetMarkerSize(2);\n", "pm3d1->SetMarkerColor(4);\n", "pm3d1->SetMarkerStyle(2);" ] }, { "cell_type": "markdown", "id": "0216a71d", "metadata": {}, "source": [ "create a second PolyMarker3D" ] }, { "cell_type": "code", "execution_count": 13, "id": "4562dcf1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:51.731231Z", "iopub.status.busy": "2026-05-19T20:36:51.731067Z", "iopub.status.idle": "2026-05-19T20:36:51.951253Z", "shell.execute_reply": "2026-05-19T20:36:51.950799Z" } }, "outputs": [], "source": [ "TPolyMarker3D *pm3d2 = new TPolyMarker3D(8);\n", "\n", "pm3d2->SetPoint(0, 22, 15, 15);\n", "pm3d2->SetPoint(1, 23, 18, 21);\n", "pm3d2->SetPoint(2, 24, 26, 13);\n", "pm3d2->SetPoint(3, 25, 17, 15);\n", "pm3d2->SetPoint(4, 26, 20, 15);\n", "pm3d2->SetPoint(5, 27, 15, 18);\n", "pm3d2->SetPoint(6, 28, 20, 10);\n", "pm3d2->SetPoint(7, 29, 20, 20);" ] }, { "cell_type": "markdown", "id": "d8b7cd1f", "metadata": {}, "source": [ "set marker size, color & style" ] }, { "cell_type": "code", "execution_count": 14, "id": "f0c3012b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:51.964301Z", "iopub.status.busy": "2026-05-19T20:36:51.964172Z", "iopub.status.idle": "2026-05-19T20:36:52.174132Z", "shell.execute_reply": "2026-05-19T20:36:52.173027Z" } }, "outputs": [], "source": [ "pm3d2->SetMarkerSize(2);\n", "pm3d2->SetMarkerColor(1);\n", "pm3d2->SetMarkerStyle(8);" ] }, { "cell_type": "markdown", "id": "4ee2eb4b", "metadata": {}, "source": [ "draw" ] }, { "cell_type": "code", "execution_count": 15, "id": "7f147301", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:52.175563Z", "iopub.status.busy": "2026-05-19T20:36:52.175450Z", "iopub.status.idle": "2026-05-19T20:36:52.385292Z", "shell.execute_reply": "2026-05-19T20:36:52.384314Z" } }, "outputs": [], "source": [ "pl3d1->Draw();\n", "pl3d2->Draw();\n", "pm3d1->Draw();\n", "pm3d2->Draw();" ] }, { "cell_type": "markdown", "id": "7f7a024c", "metadata": {}, "source": [ "draw a title/explanation in the canvas pad" ] }, { "cell_type": "code", "execution_count": 16, "id": "617b773b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:52.386986Z", "iopub.status.busy": "2026-05-19T20:36:52.386869Z", "iopub.status.idle": "2026-05-19T20:36:52.596706Z", "shell.execute_reply": "2026-05-19T20:36:52.595693Z" } }, "outputs": [], "source": [ "c1->cd();\n", "TPaveText *title = new TPaveText(0.1, 0.85, 0.9, 0.97);\n", "title->SetFillColor(24);\n", "title->AddText(\"Examples of 3-D primitives\");\n", "TText *click = title->AddText(\"Click anywhere on the picture to rotate\");\n", "click->SetTextColor(4);\n", "title->Draw();" ] }, { "cell_type": "markdown", "id": "69940303", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 17, "id": "5ad7251b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:52.598125Z", "iopub.status.busy": "2026-05-19T20:36:52.598012Z", "iopub.status.idle": "2026-05-19T20:36:52.807539Z", "shell.execute_reply": "2026-05-19T20:36:52.806669Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "