Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

home / study / engineering / computer science / computer science questions and answers / how to implement the graham's scan algorithm using jsxgraph using

home / study / engineering / computer science / computer science questions and answers / how to implement the graham's scan algorithm using jsxgraph using a code: convexhull.html i ...

Question: How to implement the GRAHAM'S SCAN algorithm using JSXGraph using a Code: ConvexHull.html I wrote...

Edit question

How to implement the GRAHAM'S SCAN algorithm using JSXGraph using a Code: ConvexHull.html

I wrote the code using Java Script - this part of the code has to be in JS Lang.

I have this code to implement a Graham's Scan algorithm using JSXGraph and this part of the code to draw a polygon on a board using a set of points.

This is the code:

I need help with implementing this part of the code:

/* The Graham's scan function */

function findConvexHull(board) {

var N = 0, P = {};

for(var el in board.objects)

if(board.objects[el].elType == 'point') {

P[N] = board.objects[el];

N++;

}

// sort the point set P; to obtain the x-coordinate of 'p', simply use 'p.X()' and similarly you can use 'p.Y()' for the y-coordinate

function p.X()

function p.Y()

// run Graham's scan to obtain the convex hull points in some order (clockwise/anticlokwise)

What to implement here?(Method)

/* draw line segments between the convex hull points to obtain the final convex polygon; to draw line segment you can simply use --> board.create('segment',[p1,p2],{fillColor: 'green',strokeColor:'green'}); where p1,p2 are the two end-points */

(How to implement the function)

board.create('segment',[p1,p2],

{fillColor: 'green',strokeColor:'green'});

}

Thanks for the help

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions